aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/utils')
-rw-r--r--server/tests/utils/miscs/miscs.ts31
1 files changed, 12 insertions, 19 deletions
diff --git a/server/tests/utils/miscs/miscs.ts b/server/tests/utils/miscs/miscs.ts
index 5e46004a7..b0667491b 100644
--- a/server/tests/utils/miscs/miscs.ts
+++ b/server/tests/utils/miscs/miscs.ts
@@ -37,25 +37,18 @@ function root () {
37} 37}
38 38
39async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') { 39async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') {
40 // Don't test images if the node env is not set 40 const res = await request(url)
41 // Because we need a special ffmpeg version for this test 41 .get(imagePath)
42 if (process.env[ 'NODE_TEST_IMAGE' ]) { 42 .expect(200)
43 const res = await request(url) 43
44 .get(imagePath) 44 const body = res.body
45 .expect(200) 45
46 46 const data = await readFileBufferPromise(join(__dirname, '..', '..', 'fixtures', imageName + extension))
47 const body = res.body 47 const minLength = body.length - ((20 * body.length) / 100)
48 48 const maxLength = body.length + ((20 * body.length) / 100)
49 const data = await readFileBufferPromise(join(__dirname, '..', '..', 'fixtures', imageName + extension)) 49
50 const minLength = body.length - ((20 * body.length) / 100) 50 expect(data.length).to.be.above(minLength)
51 const maxLength = body.length + ((20 * body.length) / 100) 51 expect(data.length).to.be.below(maxLength)
52
53 expect(data.length).to.be.above(minLength)
54 expect(data.length).to.be.below(maxLength)
55 } else {
56 console.log('Do not test images. Enable it by setting NODE_TEST_IMAGE env variable.')
57 return true
58 }
59} 52}
60 53
61function buildAbsoluteFixturePath (path: string) { 54function buildAbsoluteFixturePath (path: string) {