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