From ac81d1a06d57b9ae86663831e7f5edcef57b0fa4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Feb 2018 18:17:05 +0100 Subject: Add ability to set video thumbnail/preview --- server/tests/utils/miscs/miscs.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'server/tests/utils/miscs/miscs.ts') diff --git a/server/tests/utils/miscs/miscs.ts b/server/tests/utils/miscs/miscs.ts index 99d109bfe..24cbf59ca 100644 --- a/server/tests/utils/miscs/miscs.ts +++ b/server/tests/utils/miscs/miscs.ts @@ -1,6 +1,6 @@ /* tslint:disable:no-unused-expression */ -import { join } from 'path' +import { isAbsolute, join } from 'path' import * as request from 'supertest' import * as WebTorrent from 'webtorrent' import { readFileBufferPromise } from '../../../helpers/core-utils' @@ -45,8 +45,8 @@ async function testImage (url: string, imageName: string, imagePath: string, ext const body = res.body const data = await readFileBufferPromise(join(__dirname, '..', '..', 'api', 'fixtures', imageName + extension)) - const minLength = body.length - ((50 * body.length) / 100) - const maxLength = body.length + ((50 * body.length) / 100) + const minLength = body.length - ((20 * body.length) / 100) + const maxLength = body.length + ((20 * body.length) / 100) return data.length > minLength && data.length < maxLength } else { @@ -55,6 +55,14 @@ async function testImage (url: string, imageName: string, imagePath: string, ext } } +function buildAbsoluteFixturePath (path: string) { + if (isAbsolute(path)) { + return path + } + + return join(__dirname, '..', '..', 'api', 'fixtures', path) +} + // --------------------------------------------------------------------------- export { @@ -63,5 +71,6 @@ export { webtorrentAdd, immutableAssign, testImage, + buildAbsoluteFixturePath, root } -- cgit v1.2.3