aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/miscs/miscs.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-13 18:17:05 +0100
committerChocobozzz <me@florianbigard.com>2018-02-14 16:03:09 +0100
commitac81d1a06d57b9ae86663831e7f5edcef57b0fa4 (patch)
treeda31775c9533d3e270f68f921e146f086bf7c0b8 /server/tests/utils/miscs/miscs.ts
parente883399fa6caa56bb8519c9a2e22d88001f26661 (diff)
downloadPeerTube-ac81d1a06d57b9ae86663831e7f5edcef57b0fa4.tar.gz
PeerTube-ac81d1a06d57b9ae86663831e7f5edcef57b0fa4.tar.zst
PeerTube-ac81d1a06d57b9ae86663831e7f5edcef57b0fa4.zip
Add ability to set video thumbnail/preview
Diffstat (limited to 'server/tests/utils/miscs/miscs.ts')
-rw-r--r--server/tests/utils/miscs/miscs.ts15
1 files changed, 12 insertions, 3 deletions
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 @@
1/* tslint:disable:no-unused-expression */ 1/* tslint:disable:no-unused-expression */
2 2
3import { join } from 'path' 3import { isAbsolute, join } from 'path'
4import * as request from 'supertest' 4import * as request from 'supertest'
5import * as WebTorrent from 'webtorrent' 5import * as WebTorrent from 'webtorrent'
6import { readFileBufferPromise } from '../../../helpers/core-utils' 6import { readFileBufferPromise } from '../../../helpers/core-utils'
@@ -45,8 +45,8 @@ async function testImage (url: string, imageName: string, imagePath: string, ext
45 const body = res.body 45 const body = res.body
46 46
47 const data = await readFileBufferPromise(join(__dirname, '..', '..', 'api', 'fixtures', imageName + extension)) 47 const data = await readFileBufferPromise(join(__dirname, '..', '..', 'api', 'fixtures', imageName + extension))
48 const minLength = body.length - ((50 * body.length) / 100) 48 const minLength = body.length - ((20 * body.length) / 100)
49 const maxLength = body.length + ((50 * body.length) / 100) 49 const maxLength = body.length + ((20 * body.length) / 100)
50 50
51 return data.length > minLength && data.length < maxLength 51 return data.length > minLength && data.length < maxLength
52 } else { 52 } else {
@@ -55,6 +55,14 @@ async function testImage (url: string, imageName: string, imagePath: string, ext
55 } 55 }
56} 56}
57 57
58function buildAbsoluteFixturePath (path: string) {
59 if (isAbsolute(path)) {
60 return path
61 }
62
63 return join(__dirname, '..', '..', 'api', 'fixtures', path)
64}
65
58// --------------------------------------------------------------------------- 66// ---------------------------------------------------------------------------
59 67
60export { 68export {
@@ -63,5 +71,6 @@ export {
63 webtorrentAdd, 71 webtorrentAdd,
64 immutableAssign, 72 immutableAssign,
65 testImage, 73 testImage,
74 buildAbsoluteFixturePath,
66 root 75 root
67} 76}