diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-14 18:21:14 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-14 18:33:06 +0100 |
commit | 7b0956ec4f7753c864c4cea220e6f189327baa93 (patch) | |
tree | ed6728632a5a53bcde55978e21c2b7296c104f7e /server/tests | |
parent | 3bcfff7f446d0a1d8ef5adf340375e178259a42c (diff) | |
download | PeerTube-7b0956ec4f7753c864c4cea220e6f189327baa93.tar.gz PeerTube-7b0956ec4f7753c864c4cea220e6f189327baa93.tar.zst PeerTube-7b0956ec4f7753c864c4cea220e6f189327baa93.zip |
Fix tests
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/fixtures/avatar-resized.png | bin | 2420 -> 1727 bytes | |||
-rw-r--r-- | server/tests/api/fixtures/avatar2-resized.png | bin | 2350 -> 1725 bytes | |||
-rw-r--r-- | server/tests/api/users/users-multiple-servers.ts | 6 | ||||
-rw-r--r-- | server/tests/api/users/users.ts | 3 | ||||
-rw-r--r-- | server/tests/api/videos/multiple-servers.ts | 3 | ||||
-rw-r--r-- | server/tests/api/videos/single-server.ts | 4 | ||||
-rw-r--r-- | server/tests/api/videos/video-comments.ts | 3 | ||||
-rw-r--r-- | server/tests/utils/miscs/miscs.ts | 5 | ||||
-rw-r--r-- | server/tests/utils/videos/videos.ts | 6 |
9 files changed, 12 insertions, 18 deletions
diff --git a/server/tests/api/fixtures/avatar-resized.png b/server/tests/api/fixtures/avatar-resized.png index e05fc07ce..9d84151f8 100644 --- a/server/tests/api/fixtures/avatar-resized.png +++ b/server/tests/api/fixtures/avatar-resized.png | |||
Binary files differ | |||
diff --git a/server/tests/api/fixtures/avatar2-resized.png b/server/tests/api/fixtures/avatar2-resized.png index a2e2613bf..44149facb 100644 --- a/server/tests/api/fixtures/avatar2-resized.png +++ b/server/tests/api/fixtures/avatar2-resized.png | |||
Binary files differ | |||
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index 0483b9c3d..3c4eaff14 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts | |||
@@ -65,8 +65,7 @@ describe('Test users with multiple servers', function () { | |||
65 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) | 65 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) |
66 | user = res.body | 66 | user = res.body |
67 | 67 | ||
68 | const test = await testImage(servers[0].url, 'avatar2-resized', user.account.avatar.path, '.png') | 68 | await testImage(servers[0].url, 'avatar2-resized', user.account.avatar.path, '.png') |
69 | expect(test).to.equal(true) | ||
70 | 69 | ||
71 | await wait(5000) | 70 | await wait(5000) |
72 | }) | 71 | }) |
@@ -83,8 +82,7 @@ describe('Test users with multiple servers', function () { | |||
83 | expect(rootServer1Get.name).to.equal('root') | 82 | expect(rootServer1Get.name).to.equal('root') |
84 | expect(rootServer1Get.host).to.equal('localhost:9001') | 83 | expect(rootServer1Get.host).to.equal('localhost:9001') |
85 | 84 | ||
86 | const test = await testImage(server.url, 'avatar2-resized', rootServer1Get.avatar.path, '.png') | 85 | await testImage(server.url, 'avatar2-resized', rootServer1Get.avatar.path, '.png') |
87 | expect(test).to.equal(true) | ||
88 | } | 86 | } |
89 | }) | 87 | }) |
90 | 88 | ||
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index c23b58089..ac167d4f9 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -359,8 +359,7 @@ describe('Test users', function () { | |||
359 | const res = await getMyUserInformation(server.url, accessTokenUser) | 359 | const res = await getMyUserInformation(server.url, accessTokenUser) |
360 | const user = res.body | 360 | const user = res.body |
361 | 361 | ||
362 | const test = await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.png') | 362 | await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.png') |
363 | expect(test).to.equal(true) | ||
364 | }) | 363 | }) |
365 | 364 | ||
366 | it('Should be able to update another user', async function () { | 365 | it('Should be able to update another user', async function () { |
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 3646fbb0f..85d158d61 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -641,8 +641,7 @@ describe('Test multiple servers', function () { | |||
641 | const res = await getVideo(server.url, videoUUID) | 641 | const res = await getVideo(server.url, videoUUID) |
642 | const video = res.body | 642 | const video = res.body |
643 | 643 | ||
644 | const test = await testImage(server.url, 'video_short1-preview.webm', video.previewPath) | 644 | await testImage(server.url, 'video_short1-preview.webm', video.previewPath) |
645 | expect(test).to.equal(true) | ||
646 | } | 645 | } |
647 | }) | 646 | }) |
648 | }) | 647 | }) |
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index 476a25479..8f55075fb 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts | |||
@@ -341,9 +341,7 @@ describe('Test a single server', function () { | |||
341 | 341 | ||
342 | for (const video of videos) { | 342 | for (const video of videos) { |
343 | const videoName = video.name.replace(' name', '') | 343 | const videoName = video.name.replace(' name', '') |
344 | const test = await testImage(server.url, videoName, video.thumbnailPath) | 344 | await testImage(server.url, videoName, video.thumbnailPath) |
345 | |||
346 | expect(test).to.equal(true) | ||
347 | } | 345 | } |
348 | }) | 346 | }) |
349 | 347 | ||
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts index cf8166a96..f83d95088 100644 --- a/server/tests/api/videos/video-comments.ts +++ b/server/tests/api/videos/video-comments.ts | |||
@@ -83,8 +83,7 @@ describe('Test video comments', function () { | |||
83 | expect(comment.account.name).to.equal('root') | 83 | expect(comment.account.name).to.equal('root') |
84 | expect(comment.account.host).to.equal('localhost:9001') | 84 | expect(comment.account.host).to.equal('localhost:9001') |
85 | 85 | ||
86 | const test = await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png') | 86 | await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png') |
87 | expect(test).to.equal(true) | ||
88 | 87 | ||
89 | expect(comment.totalReplies).to.equal(0) | 88 | expect(comment.totalReplies).to.equal(0) |
90 | expect(dateIsValid(comment.createdAt as string)).to.be.true | 89 | expect(dateIsValid(comment.createdAt as string)).to.be.true |
diff --git a/server/tests/utils/miscs/miscs.ts b/server/tests/utils/miscs/miscs.ts index 24cbf59ca..53cb67baf 100644 --- a/server/tests/utils/miscs/miscs.ts +++ b/server/tests/utils/miscs/miscs.ts | |||
@@ -1,10 +1,12 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* tslint:disable:no-unused-expression */ |
2 | 2 | ||
3 | import * as chai from 'chai' | ||
3 | import { isAbsolute, join } from 'path' | 4 | import { isAbsolute, join } from 'path' |
4 | import * as request from 'supertest' | 5 | import * as request from 'supertest' |
5 | import * as WebTorrent from 'webtorrent' | 6 | import * as WebTorrent from 'webtorrent' |
6 | import { readFileBufferPromise } from '../../../helpers/core-utils' | 7 | import { readFileBufferPromise } from '../../../helpers/core-utils' |
7 | 8 | ||
9 | const expect = chai.expect | ||
8 | let webtorrent = new WebTorrent() | 10 | let webtorrent = new WebTorrent() |
9 | 11 | ||
10 | function immutableAssign <T, U> (target: T, source: U) { | 12 | function immutableAssign <T, U> (target: T, source: U) { |
@@ -48,7 +50,8 @@ async function testImage (url: string, imageName: string, imagePath: string, ext | |||
48 | const minLength = body.length - ((20 * body.length) / 100) | 50 | const minLength = body.length - ((20 * body.length) / 100) |
49 | const maxLength = body.length + ((20 * body.length) / 100) | 51 | const maxLength = body.length + ((20 * body.length) / 100) |
50 | 52 | ||
51 | return data.length > minLength && data.length < maxLength | 53 | expect(data.length).to.be.above(minLength) |
54 | expect(data.length).to.be.below(maxLength) | ||
52 | } else { | 55 | } else { |
53 | console.log('Do not test images. Enable it by setting NODE_TEST_IMAGE env variable.') | 56 | console.log('Do not test images. Enable it by setting NODE_TEST_IMAGE env variable.') |
54 | return true | 57 | return true |
diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index 8e58f1f0c..9a4af0b9f 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts | |||
@@ -445,13 +445,11 @@ async function completeVideoCheck ( | |||
445 | expect(file.size).to.be.above(minSize).and.below(maxSize) | 445 | expect(file.size).to.be.above(minSize).and.below(maxSize) |
446 | 446 | ||
447 | { | 447 | { |
448 | const test = await testImage(url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath) | 448 | await testImage(url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath) |
449 | expect(test).to.equal(true) | ||
450 | } | 449 | } |
451 | 450 | ||
452 | if (attributes.previewfile) { | 451 | if (attributes.previewfile) { |
453 | const test = await testImage(url, attributes.previewfile, videoDetails.previewPath) | 452 | await testImage(url, attributes.previewfile, videoDetails.previewPath) |
454 | expect(test).to.equal(true) | ||
455 | } | 453 | } |
456 | 454 | ||
457 | const torrent = await webtorrentAdd(magnetUri, true) | 455 | const torrent = await webtorrentAdd(magnetUri, true) |