1 /* eslint-disable @typescript-eslint/no-floating-promises */
3 import * as request from 'supertest'
4 import { makeDeleteRequest } from '../requests/requests'
6 function getVideoCommentThreads (url: string, videoId: number | string, start: number, count: number, sort?: string, token?: string) {
7 const path = '/api/v1/videos/' + videoId + '/comment-threads'
9 const req = request(url)
11 .query({ start: start })
12 .query({ count: count })
14 if (sort) req.query({ sort })
15 if (token) req.set('Authorization', 'Bearer ' + token)
17 return req.set('Accept', 'application/json')
19 .expect('Content-Type', /json/)
22 function getVideoThreadComments (url: string, videoId: number | string, threadId: number, token?: string) {
23 const path = '/api/v1/videos/' + videoId + '/comment-threads/' + threadId
25 const req = request(url)
27 .set('Accept', 'application/json')
29 if (token) req.set('Authorization', 'Bearer ' + token)
31 return req.expect(200)
32 .expect('Content-Type', /json/)
35 function addVideoCommentThread (url: string, token: string, videoId: number | string, text: string, expectedStatus = 200) {
36 const path = '/api/v1/videos/' + videoId + '/comment-threads'
41 .set('Accept', 'application/json')
42 .set('Authorization', 'Bearer ' + token)
43 .expect(expectedStatus)
46 function addVideoCommentReply (
49 videoId: number | string,
50 inReplyToCommentId: number,
54 const path = '/api/v1/videos/' + videoId + '/comments/' + inReplyToCommentId
59 .set('Accept', 'application/json')
60 .set('Authorization', 'Bearer ' + token)
61 .expect(expectedStatus)
64 function deleteVideoComment (
67 videoId: number | string,
69 statusCodeExpected = 204
71 const path = '/api/v1/videos/' + videoId + '/comments/' + commentId
73 return makeDeleteRequest({
81 // ---------------------------------------------------------------------------
84 getVideoCommentThreads,
85 getVideoThreadComments,
86 addVideoCommentThread,