1 import { makeDeleteRequest, makeGetRequest } from '../'
2 import { buildAbsoluteFixturePath, makeUploadRequest } from '../index'
3 import * as request from 'supertest'
4 import * as chai from 'chai'
6 const expect = chai.expect
8 function createVideoCaption (args: {
11 videoId: string | number
15 const path = '/api/v1/videos/' + args.videoId + '/captions/' + args.language
17 return makeUploadRequest({
21 token: args.accessToken,
24 captionfile: buildAbsoluteFixturePath(args.fixture)
26 statusCodeExpected: 204
30 function listVideoCaptions (url: string, videoId: string | number) {
31 const path = '/api/v1/videos/' + videoId + '/captions'
33 return makeGetRequest({
36 statusCodeExpected: 200
40 function deleteVideoCaption (url: string, token: string, videoId: string | number, language: string) {
41 const path = '/api/v1/videos/' + videoId + '/captions/' + language
43 return makeDeleteRequest({
47 statusCodeExpected: 204
51 async function testCaptionFile (url: string, captionPath: string, containsString: string) {
52 const res = await request(url)
56 expect(res.text).to.contain(containsString)
59 // ---------------------------------------------------------------------------