1 import * as request from 'supertest'
2 import { makeDeleteRequest } from '../requests/requests'
4 function getVideoCommentThreads (url: string, videoId: number | string, start: number, count: number, sort?: string, token?: 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 })
13 if (token) req.set('Authorization', 'Bearer ' + token)
15 return req.set('Accept', 'application/json')
17 .expect('Content-Type', /json/)
20 function getVideoThreadComments (url: string, videoId: number | string, threadId: number, token?: string) {
21 const path = '/api/v1/videos/' + videoId + '/comment-threads/' + threadId
23 const req = request(url)
25 .set('Accept', 'application/json')
27 if (token) req.set('Authorization', 'Bearer ' + token)
29 return req.expect(200)
30 .expect('Content-Type', /json/)
33 function addVideoCommentThread (url: string, token: string, videoId: number | string, text: string, expectedStatus = 200) {
34 const path = '/api/v1/videos/' + videoId + '/comment-threads'
39 .set('Accept', 'application/json')
40 .set('Authorization', 'Bearer ' + token)
41 .expect(expectedStatus)
44 function addVideoCommentReply (
47 videoId: number | string,
48 inReplyToCommentId: number,
52 const path = '/api/v1/videos/' + videoId + '/comments/' + inReplyToCommentId
57 .set('Accept', 'application/json')
58 .set('Authorization', 'Bearer ' + token)
59 .expect(expectedStatus)
62 function deleteVideoComment (
65 videoId: number | string,
67 statusCodeExpected = 204
69 const path = '/api/v1/videos/' + videoId + '/comments/' + commentId
71 return makeDeleteRequest({
79 // ---------------------------------------------------------------------------
82 getVideoCommentThreads,
83 getVideoThreadComments,
84 addVideoCommentThread,