diff options
Diffstat (limited to 'server/tests/utils')
-rw-r--r-- | server/tests/utils/video-abuses.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/server/tests/utils/video-abuses.js b/server/tests/utils/video-abuses.js new file mode 100644 index 000000000..596c824b3 --- /dev/null +++ b/server/tests/utils/video-abuses.js | |||
@@ -0,0 +1,73 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | const request = require('supertest') | ||
4 | |||
5 | const videosUtils = { | ||
6 | getVideoAbusesList, | ||
7 | getVideoAbusesListPagination, | ||
8 | getVideoAbusesListSort, | ||
9 | reportVideoAbuse | ||
10 | } | ||
11 | |||
12 | // ---------------------- Export functions -------------------- | ||
13 | |||
14 | function reportVideoAbuse (url, token, videoId, reason, specialStatus, end) { | ||
15 | if (!end) { | ||
16 | end = specialStatus | ||
17 | specialStatus = 204 | ||
18 | } | ||
19 | |||
20 | const path = '/api/v1/videos/' + videoId + '/abuse' | ||
21 | |||
22 | request(url) | ||
23 | .post(path) | ||
24 | .set('Accept', 'application/json') | ||
25 | .set('Authorization', 'Bearer ' + token) | ||
26 | .send({ reason }) | ||
27 | .expect(specialStatus) | ||
28 | .end(end) | ||
29 | } | ||
30 | |||
31 | function getVideoAbusesList (url, token, end) { | ||
32 | const path = '/api/v1/videos/abuse' | ||
33 | |||
34 | request(url) | ||
35 | .get(path) | ||
36 | .query({ sort: 'createdAt' }) | ||
37 | .set('Accept', 'application/json') | ||
38 | .set('Authorization', 'Bearer ' + token) | ||
39 | .expect(200) | ||
40 | .expect('Content-Type', /json/) | ||
41 | .end(end) | ||
42 | } | ||
43 | |||
44 | function getVideoAbusesListPagination (url, token, start, count, end) { | ||
45 | const path = '/api/v1/videos/abuse' | ||
46 | |||
47 | request(url) | ||
48 | .get(path) | ||
49 | .query({ start: start }) | ||
50 | .query({ count: count }) | ||
51 | .set('Accept', 'application/json') | ||
52 | .set('Authorization', 'Bearer ' + token) | ||
53 | .expect(200) | ||
54 | .expect('Content-Type', /json/) | ||
55 | .end(end) | ||
56 | } | ||
57 | |||
58 | function getVideoAbusesListSort (url, token, sort, end) { | ||
59 | const path = '/api/v1/videos/abuse' | ||
60 | |||
61 | request(url) | ||
62 | .get(path) | ||
63 | .query({ sort: sort }) | ||
64 | .set('Accept', 'application/json') | ||
65 | .set('Authorization', 'Bearer ' + token) | ||
66 | .expect(200) | ||
67 | .expect('Content-Type', /json/) | ||
68 | .end(end) | ||
69 | } | ||
70 | |||
71 | // --------------------------------------------------------------------------- | ||
72 | |||
73 | module.exports = videosUtils | ||