diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-28 13:59:22 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-28 13:59:22 +0100 |
commit | c5d31dba56d669c0df0209761c43c5a6ac7cec4a (patch) | |
tree | fe72b56a1c0e7beb6e092c393a00ddfe93a5d71f /server/tests/utils/videos/video-comments.ts | |
parent | db799da3d2b2ea465165df78ff71effa653b6309 (diff) | |
download | PeerTube-c5d31dba56d669c0df0209761c43c5a6ac7cec4a.tar.gz PeerTube-c5d31dba56d669c0df0209761c43c5a6ac7cec4a.tar.zst PeerTube-c5d31dba56d669c0df0209761c43c5a6ac7cec4a.zip |
Tests directories refractor
Diffstat (limited to 'server/tests/utils/videos/video-comments.ts')
-rw-r--r-- | server/tests/utils/videos/video-comments.ts | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/server/tests/utils/videos/video-comments.ts b/server/tests/utils/videos/video-comments.ts new file mode 100644 index 000000000..878147049 --- /dev/null +++ b/server/tests/utils/videos/video-comments.ts | |||
@@ -0,0 +1,64 @@ | |||
1 | import * as request from 'supertest' | ||
2 | |||
3 | function getVideoCommentThreads (url: string, videoId: number | string, start: number, count: number, sort?: string) { | ||
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 | |||
18 | function getVideoThreadComments (url: string, videoId: number | string, threadId: number) { | ||
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 | |||
28 | function addVideoCommentThread (url: string, token: string, videoId: number | string, text: string, expectedStatus = 200) { | ||
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, | ||
42 | videoId: number | string, | ||
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 | } | ||