From 40e87e9ecc54e3513fb586928330a7855eb192c6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 12 Jul 2018 19:02:00 +0200 Subject: Implement captions/subtitles --- server/tests/utils/videos/video-captions.ts | 66 +++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 server/tests/utils/videos/video-captions.ts (limited to 'server/tests/utils/videos') diff --git a/server/tests/utils/videos/video-captions.ts b/server/tests/utils/videos/video-captions.ts new file mode 100644 index 000000000..207e89632 --- /dev/null +++ b/server/tests/utils/videos/video-captions.ts @@ -0,0 +1,66 @@ +import { makeDeleteRequest, makeGetRequest } from '../' +import { buildAbsoluteFixturePath, makeUploadRequest } from '../index' +import * as request from 'supertest' +import * as chai from 'chai' + +const expect = chai.expect + +function createVideoCaption (args: { + url: string, + accessToken: string + videoId: string | number + language: string + fixture: string +}) { + const path = '/api/v1/videos/' + args.videoId + '/captions/' + args.language + + return makeUploadRequest({ + method: 'PUT', + url: args.url, + path, + token: args.accessToken, + fields: {}, + attaches: { + captionfile: buildAbsoluteFixturePath(args.fixture) + }, + statusCodeExpected: 204 + }) +} + +function listVideoCaptions (url: string, videoId: string | number) { + const path = '/api/v1/videos/' + videoId + '/captions' + + return makeGetRequest({ + url, + path, + statusCodeExpected: 200 + }) +} + +function deleteVideoCaption (url: string, token: string, videoId: string | number, language: string) { + const path = '/api/v1/videos/' + videoId + '/captions/' + language + + return makeDeleteRequest({ + url, + token, + path, + statusCodeExpected: 204 + }) +} + +async function testCaptionFile (url: string, captionPath: string, containsString: string) { + const res = await request(url) + .get(captionPath) + .expect(200) + + expect(res.text).to.contain(containsString) +} + +// --------------------------------------------------------------------------- + +export { + createVideoCaption, + listVideoCaptions, + testCaptionFile, + deleteVideoCaption +} -- cgit v1.2.3