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