PeerTube/packages/tests/src/shared/captions.ts

22 lines
545 B
TypeScript
Raw Normal View History

2021-07-08 11:49:38 +02:00
import { expect } from 'chai'
2021-08-27 14:32:44 +02:00
import request from 'supertest'
import { HttpStatusCode } from '@peertube/peertube-models'
2021-07-08 11:49:38 +02:00
async function testCaptionFile (url: string, captionPath: string, toTest: RegExp | string) {
2021-07-08 11:49:38 +02:00
const res = await request(url)
.get(captionPath)
.expect(HttpStatusCode.OK_200)
if (toTest instanceof RegExp) {
expect(res.text).to.match(toTest)
} else {
expect(res.text).to.contain(toTest)
}
2021-07-08 11:49:38 +02:00
}
// ---------------------------------------------------------------------------
export {
testCaptionFile
}