aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/video-abuses.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/utils/video-abuses.ts')
-rw-r--r--server/tests/utils/video-abuses.ts58
1 files changed, 58 insertions, 0 deletions
diff --git a/server/tests/utils/video-abuses.ts b/server/tests/utils/video-abuses.ts
new file mode 100644
index 000000000..f7ee958d7
--- /dev/null
+++ b/server/tests/utils/video-abuses.ts
@@ -0,0 +1,58 @@
1import * as request from 'supertest'
2
3function reportVideoAbuse (url: string, token: string, videoId: number, reason: string, specialStatus = 204) {
4 const path = '/api/v1/videos/' + videoId + '/abuse'
5
6 return request(url)
7 .post(path)
8 .set('Accept', 'application/json')
9 .set('Authorization', 'Bearer ' + token)
10 .send({ reason })
11 .expect(specialStatus)
12}
13
14function getVideoAbusesList (url: string, token: string) {
15 const path = '/api/v1/videos/abuse'
16
17 return request(url)
18 .get(path)
19 .query({ sort: 'createdAt' })
20 .set('Accept', 'application/json')
21 .set('Authorization', 'Bearer ' + token)
22 .expect(200)
23 .expect('Content-Type', /json/)
24}
25
26function getVideoAbusesListPagination (url: string, token: string, start: number, count: number) {
27 const path = '/api/v1/videos/abuse'
28
29 return request(url)
30 .get(path)
31 .query({ start: start })
32 .query({ count: count })
33 .set('Accept', 'application/json')
34 .set('Authorization', 'Bearer ' + token)
35 .expect(200)
36 .expect('Content-Type', /json/)
37}
38
39function getVideoAbusesListSort (url: string, token: string, sort: string) {
40 const path = '/api/v1/videos/abuse'
41
42 return request(url)
43 .get(path)
44 .query({ sort: sort })
45 .set('Accept', 'application/json')
46 .set('Authorization', 'Bearer ' + token)
47 .expect(200)
48 .expect('Content-Type', /json/)
49}
50
51// ---------------------------------------------------------------------------
52
53export {
54 reportVideoAbuse,
55 getVideoAbusesList,
56 getVideoAbusesListPagination,
57 getVideoAbusesListSort
58}