]>
Commit | Line | Data |
---|---|---|
d3ea8975 C |
1 | import * as request from 'supertest' |
2 | ||
d50acfab | 3 | function getVideoCommentThreads (url: string, videoId: number | string, start: number, count: number, sort?: string) { |
d3ea8975 C |
4 | const path = '/api/v1/videos/' + videoId + '/comment-threads' |
5 | ||
6 | const req = request(url) | |
7 | .get(path) | |
8 | .query({ start: start }) | |
9 | .query({ count: count }) | |
10 | ||
11 | if (sort) req.query({ sort }) | |
12 | ||
13 | return req.set('Accept', 'application/json') | |
14 | .expect(200) | |
15 | .expect('Content-Type', /json/) | |
16 | } | |
17 | ||
d50acfab | 18 | function getVideoThreadComments (url: string, videoId: number | string, threadId: number) { |
d3ea8975 C |
19 | const path = '/api/v1/videos/' + videoId + '/comment-threads/' + threadId |
20 | ||
21 | return request(url) | |
22 | .get(path) | |
23 | .set('Accept', 'application/json') | |
24 | .expect(200) | |
25 | .expect('Content-Type', /json/) | |
26 | } | |
27 | ||
e2e22e40 | 28 | function addVideoCommentThread (url: string, token: string, videoId: number | string, text: string, expectedStatus = 200) { |
d3ea8975 C |
29 | const path = '/api/v1/videos/' + videoId + '/comment-threads' |
30 | ||
31 | return request(url) | |
32 | .post(path) | |
33 | .send({ text }) | |
34 | .set('Accept', 'application/json') | |
35 | .set('Authorization', 'Bearer ' + token) | |
36 | .expect(expectedStatus) | |
37 | } | |
38 | ||
39 | function addVideoCommentReply ( | |
40 | url: string, | |
41 | token: string, | |
d50acfab | 42 | videoId: number | string, |
d3ea8975 C |
43 | inReplyToCommentId: number, |
44 | text: string, | |
45 | expectedStatus = 200 | |
46 | ) { | |
47 | const path = '/api/v1/videos/' + videoId + '/comments/' + inReplyToCommentId | |
48 | ||
49 | return request(url) | |
50 | .post(path) | |
51 | .send({ text }) | |
52 | .set('Accept', 'application/json') | |
53 | .set('Authorization', 'Bearer ' + token) | |
54 | .expect(expectedStatus) | |
55 | } | |
56 | ||
57 | // --------------------------------------------------------------------------- | |
58 | ||
59 | export { | |
60 | getVideoCommentThreads, | |
61 | getVideoThreadComments, | |
62 | addVideoCommentThread, | |
63 | addVideoCommentReply | |
64 | } |