]>
Commit | Line | Data |
---|---|---|
792dbaf0 GS |
1 | import * as request from 'supertest' |
2 | ||
26b7305a | 3 | function addVideoToBlacklist (url: string, token: string, videoId: number | string, reason?: string, specialStatus = 204) { |
792dbaf0 GS |
4 | const path = '/api/v1/videos/' + videoId + '/blacklist' |
5 | ||
6 | return request(url) | |
7 | .post(path) | |
26b7305a | 8 | .send({ reason }) |
792dbaf0 GS |
9 | .set('Accept', 'application/json') |
10 | .set('Authorization', 'Bearer ' + token) | |
11 | .expect(specialStatus) | |
12 | } | |
13 | ||
26b7305a C |
14 | function updateVideoBlacklist (url: string, token: string, videoId: number, reason?: string, specialStatus = 204) { |
15 | const path = '/api/v1/videos/' + videoId + '/blacklist' | |
16 | ||
17 | return request(url) | |
18 | .put(path) | |
19 | .send({ reason }) | |
20 | .set('Accept', 'application/json') | |
21 | .set('Authorization', 'Bearer ' + token) | |
22 | .expect(specialStatus)} | |
23 | ||
11ba2ab3 | 24 | function removeVideoFromBlacklist (url: string, token: string, videoId: number | string, specialStatus = 204) { |
35bf0c83 | 25 | const path = '/api/v1/videos/' + videoId + '/blacklist' |
792dbaf0 GS |
26 | |
27 | return request(url) | |
28 | .delete(path) | |
29 | .set('Accept', 'application/json') | |
30 | .set('Authorization', 'Bearer ' + token) | |
31 | .expect(specialStatus) | |
32 | } | |
33 | ||
34 | function getBlacklistedVideosList (url: string, token: string, specialStatus = 200) { | |
35bf0c83 | 35 | const path = '/api/v1/videos/blacklist/' |
792dbaf0 GS |
36 | |
37 | return request(url) | |
38 | .get(path) | |
39 | .query({ sort: 'createdAt' }) | |
40 | .set('Accept', 'application/json') | |
41 | .set('Authorization', 'Bearer ' + token) | |
42 | .expect(specialStatus) | |
43 | .expect('Content-Type', /json/) | |
44 | } | |
45 | ||
46 | function getSortedBlacklistedVideosList (url: string, token: string, sort: string, specialStatus = 200) { | |
35bf0c83 | 47 | const path = '/api/v1/videos/blacklist/' |
792dbaf0 GS |
48 | |
49 | return request(url) | |
50 | .get(path) | |
51 | .query({ sort: sort }) | |
52 | .set('Accept', 'application/json') | |
53 | .set('Authorization', 'Bearer ' + token) | |
54 | .expect(specialStatus) | |
55 | .expect('Content-Type', /json/) | |
56 | } | |
57 | ||
58 | // --------------------------------------------------------------------------- | |
59 | ||
60 | export { | |
61 | addVideoToBlacklist, | |
62 | removeVideoFromBlacklist, | |
63 | getBlacklistedVideosList, | |
26b7305a C |
64 | getSortedBlacklistedVideosList, |
65 | updateVideoBlacklist | |
792dbaf0 | 66 | } |