aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/videos/video-comments.ts
diff options
context:
space:
mode:
authorbuoyantair <buoyantair@gmail.com>2018-10-29 22:18:31 +0530
committerbuoyantair <buoyantair@gmail.com>2018-10-29 22:18:31 +0530
commit9639bd175726b73f8fe664b5ced12a72407b1f0b (patch)
tree689d4c9e0a1f8dcc55e0ba4e694af3b09bff2cad /server/tests/utils/videos/video-comments.ts
parent71607e4a65d3a8904bcd418ab7acbc2f34f725ff (diff)
downloadPeerTube-9639bd175726b73f8fe664b5ced12a72407b1f0b.tar.gz
PeerTube-9639bd175726b73f8fe664b5ced12a72407b1f0b.tar.zst
PeerTube-9639bd175726b73f8fe664b5ced12a72407b1f0b.zip
Move utils to /shared
Move utils used by /server/tools/* & /server/tests/**/* into /shared folder. Issue: #1336
Diffstat (limited to 'server/tests/utils/videos/video-comments.ts')
-rw-r--r--server/tests/utils/videos/video-comments.ts87
1 files changed, 0 insertions, 87 deletions
diff --git a/server/tests/utils/videos/video-comments.ts b/server/tests/utils/videos/video-comments.ts
deleted file mode 100644
index 7d4cae364..000000000
--- a/server/tests/utils/videos/video-comments.ts
+++ /dev/null
@@ -1,87 +0,0 @@
1import * as request from 'supertest'
2import { makeDeleteRequest } from '../'
3
4function getVideoCommentThreads (url: string, videoId: number | string, start: number, count: number, sort?: string, token?: 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 if (token) req.set('Authorization', 'Bearer ' + token)
14
15 return req.set('Accept', 'application/json')
16 .expect(200)
17 .expect('Content-Type', /json/)
18}
19
20function getVideoThreadComments (url: string, videoId: number | string, threadId: number, token?: string) {
21 const path = '/api/v1/videos/' + videoId + '/comment-threads/' + threadId
22
23 const req = request(url)
24 .get(path)
25 .set('Accept', 'application/json')
26
27 if (token) req.set('Authorization', 'Bearer ' + token)
28
29 return req.expect(200)
30 .expect('Content-Type', /json/)
31}
32
33function addVideoCommentThread (url: string, token: string, videoId: number | string, text: string, expectedStatus = 200) {
34 const path = '/api/v1/videos/' + videoId + '/comment-threads'
35
36 return request(url)
37 .post(path)
38 .send({ text })
39 .set('Accept', 'application/json')
40 .set('Authorization', 'Bearer ' + token)
41 .expect(expectedStatus)
42}
43
44function addVideoCommentReply (
45 url: string,
46 token: string,
47 videoId: number | string,
48 inReplyToCommentId: number,
49 text: string,
50 expectedStatus = 200
51) {
52 const path = '/api/v1/videos/' + videoId + '/comments/' + inReplyToCommentId
53
54 return request(url)
55 .post(path)
56 .send({ text })
57 .set('Accept', 'application/json')
58 .set('Authorization', 'Bearer ' + token)
59 .expect(expectedStatus)
60}
61
62function deleteVideoComment (
63 url: string,
64 token: string,
65 videoId: number | string,
66 commentId: number,
67 statusCodeExpected = 204
68) {
69 const path = '/api/v1/videos/' + videoId + '/comments/' + commentId
70
71 return makeDeleteRequest({
72 url,
73 path,
74 token,
75 statusCodeExpected
76 })
77}
78
79// ---------------------------------------------------------------------------
80
81export {
82 getVideoCommentThreads,
83 getVideoThreadComments,
84 addVideoCommentThread,
85 addVideoCommentReply,
86 deleteVideoComment
87}