aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/miscs
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/utils/miscs')
-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}