aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/videos/video-comments.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-02-11 11:52:34 +0100
committerChocobozzz <me@florianbigard.com>2019-02-11 11:52:34 +0100
commit88108880bbdba473cfe36ecbebc1c3c4f972e102 (patch)
treeb242efb3b4f0d7e49d88f2d1f2063b5b3b0489c0 /server/tests/utils/videos/video-comments.ts
parent53a94c7cfa8368da4cd248d65df8346905938f0c (diff)
parent9b712a2017e4ab3cf12cd6bd58278905520159d0 (diff)
downloadPeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.gz
PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.zst
PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.zip
Merge branch 'develop' into pr/1217
Diffstat (limited to 'server/tests/utils/videos/video-comments.ts')
-rw-r--r--server/tests/utils/videos/video-comments.ts83
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 @@
1import * as request from 'supertest'
2import { makeDeleteRequest } from '../'
3
4function 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
19function 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
29function 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
40function 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
58function 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
77export {
78 getVideoCommentThreads,
79 getVideoThreadComments,
80 addVideoCommentThread,
81 addVideoCommentReply,
82 deleteVideoComment
83}