1 import * as request from 'supertest'
2 import { makeDeleteRequest } from '../'
4 function getVideoCommentThreads (url: string, videoId: number | string, start: number, count: number, sort?: string) {
5 const path = '/api/v1/videos/' + videoId + '/comment-threads'
7 const req = request(url)
9 .query({ start: start })
10 .query({ count: count })
12 if (sort) req.query({ sort })
14 return req.set('Accept', 'application/json')
16 .expect('Content-Type', /json/)
19 function getVideoThreadComments (url: string, videoId: number | string, threadId: number) {
20 const path = '/api/v1/videos/' + videoId + '/comment-threads/' + threadId
24 .set('Accept', 'application/json')
26 .expect('Content-Type', /json/)
29 function addVideoCommentThread (url: string, token: string, videoId: number | string, text: string, expectedStatus = 200) {
30 const path = '/api/v1/videos/' + videoId + '/comment-threads'
35 .set('Accept', 'application/json')
36 .set('Authorization', 'Bearer ' + token)
37 .expect(expectedStatus)
40 function addVideoCommentReply (
43 videoId: number | string,
44 inReplyToCommentId: number,
48 const path = '/api/v1/videos/' + videoId + '/comments/' + inReplyToCommentId
53 .set('Accept', 'application/json')
54 .set('Authorization', 'Bearer ' + token)
55 .expect(expectedStatus)
58 function deleteVideoComment (
61 videoId: number | string,
63 statusCodeExpected = 204
65 const path = '/api/v1/videos/' + videoId + '/comments/' + commentId
67 return makeDeleteRequest({
75 // ---------------------------------------------------------------------------
78 getVideoCommentThreads,
79 getVideoThreadComments,
80 addVideoCommentThread,