diff options
Diffstat (limited to 'server/tests/utils/videos/video-comments.ts')
-rw-r--r-- | server/tests/utils/videos/video-comments.ts | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/server/tests/utils/videos/video-comments.ts b/server/tests/utils/videos/video-comments.ts deleted file mode 100644 index 1b9ee452e..000000000 --- a/server/tests/utils/videos/video-comments.ts +++ /dev/null | |||
@@ -1,83 +0,0 @@ | |||
1 | import * as request from 'supertest' | ||
2 | import { makeDeleteRequest } from '../' | ||
3 | |||
4 | function getVideoCommentThreads (url: string, videoId: number | string, start: number, count: number, sort?: string) { | ||
5 | const path = '/api/v1/videos/' + videoId + '/comment-threads' | ||
6 | |||
7 | const req = request(url) | ||
8 | .get(path) | ||
9 | .query({ start: start }) | ||
10 | .query({ count: count }) | ||
11 | |||
12 | if (sort) req.query({ sort }) | ||
13 | |||
14 | return req.set('Accept', 'application/json') | ||
15 | .expect(200) | ||
16 | .expect('Content-Type', /json/) | ||
17 | } | ||
18 | |||
19 | function getVideoThreadComments (url: string, videoId: number | string, threadId: number) { | ||
20 | const path = '/api/v1/videos/' + videoId + '/comment-threads/' + threadId | ||
21 | |||
22 | return request(url) | ||
23 | .get(path) | ||
24 | .set('Accept', 'application/json') | ||
25 | .expect(200) | ||
26 | .expect('Content-Type', /json/) | ||
27 | } | ||
28 | |||
29 | function addVideoCommentThread (url: string, token: string, videoId: number | string, text: string, expectedStatus = 200) { | ||
30 | const path = '/api/v1/videos/' + videoId + '/comment-threads' | ||
31 | |||
32 | return request(url) | ||
33 | .post(path) | ||
34 | .send({ text }) | ||
35 | .set('Accept', 'application/json') | ||
36 | .set('Authorization', 'Bearer ' + token) | ||
37 | .expect(expectedStatus) | ||
38 | } | ||
39 | |||
40 | function addVideoCommentReply ( | ||
41 | url: string, | ||
42 | token: string, | ||
43 | videoId: number | string, | ||
44 | inReplyToCommentId: number, | ||
45 | text: string, | ||
46 | expectedStatus = 200 | ||
47 | ) { | ||
48 | const path = '/api/v1/videos/' + videoId + '/comments/' + inReplyToCommentId | ||
49 | |||
50 | return request(url) | ||
51 | .post(path) | ||
52 | .send({ text }) | ||
53 | .set('Accept', 'application/json') | ||
54 | .set('Authorization', 'Bearer ' + token) | ||
55 | .expect(expectedStatus) | ||
56 | } | ||
57 | |||
58 | function deleteVideoComment ( | ||
59 | url: string, | ||
60 | token: string, | ||
61 | videoId: number | string, | ||
62 | commentId: number, | ||
63 | statusCodeExpected = 204 | ||
64 | ) { | ||
65 | const path = '/api/v1/videos/' + videoId + '/comments/' + commentId | ||
66 | |||
67 | return makeDeleteRequest({ | ||
68 | url, | ||
69 | path, | ||
70 | token, | ||
71 | statusCodeExpected | ||
72 | }) | ||
73 | } | ||
74 | |||
75 | // --------------------------------------------------------------------------- | ||
76 | |||
77 | export { | ||
78 | getVideoCommentThreads, | ||
79 | getVideoThreadComments, | ||
80 | addVideoCommentThread, | ||
81 | addVideoCommentReply, | ||
82 | deleteVideoComment | ||
83 | } | ||