1 import { makeDeleteRequest, makeGetRequest, makeUploadRequest } from '../requests/requests'
2 import * as request from 'supertest'
3 import * as chai from 'chai'
4 import { buildAbsoluteFixturePath } from '../miscs/miscs'
6 const expect = chai.expect
8 function createVideoCaption (args: {
11 videoId: string | number
15 statusCodeExpected?: number
17 const path = '/api/v1/videos/' + args.videoId + '/captions/' + args.language
19 const captionfile = buildAbsoluteFixturePath(args.fixture)
20 const captionfileAttach = args.mimeType ? [ captionfile, { contentType: args.mimeType } ] : captionfile
22 return makeUploadRequest({
26 token: args.accessToken,
29 captionfile: captionfileAttach
31 statusCodeExpected: args.statusCodeExpected || 204
35 function listVideoCaptions (url: string, videoId: string | number) {
36 const path = '/api/v1/videos/' + videoId + '/captions'
38 return makeGetRequest({
41 statusCodeExpected: 200
45 function deleteVideoCaption (url: string, token: string, videoId: string | number, language: string) {
46 const path = '/api/v1/videos/' + videoId + '/captions/' + language
48 return makeDeleteRequest({
52 statusCodeExpected: 204
56 async function testCaptionFile (url: string, captionPath: string, containsString: string) {
57 const res = await request(url)
61 expect(res.text).to.contain(containsString)
64 // ---------------------------------------------------------------------------