From c49db162ee3ad0acf89f4e71ac0083b30ab798ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 4 Apr 2018 10:21:36 +0200 Subject: [PATCH] Add tests for publishedAt --- server/tests/api/videos/video-privacy.ts | 9 ++++++--- server/tests/utils/videos/videos.ts | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts index 469274921..8ab37189a 100644 --- a/server/tests/api/videos/video-privacy.ts +++ b/server/tests/api/videos/video-privacy.ts @@ -22,9 +22,10 @@ const expect = chai.expect describe('Test video privacy', function () { let servers: ServerInfo[] = [] - let privateVideoId - let privateVideoUUID - let unlistedVideoUUID + let privateVideoId: number + let privateVideoUUID: string + let unlistedVideoUUID: string + let now: number before(async function () { this.timeout(50000) @@ -133,6 +134,7 @@ describe('Test video privacy', function () { privacy: VideoPrivacy.PUBLIC } + now = Date.now() await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, attribute) await wait(5000) @@ -145,6 +147,7 @@ describe('Test video privacy', function () { expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) expect(res.body.data[0].name).to.equal('super video public') + expect(new Date(res.body.data[0].publishedAt).getTime()).to.be.at.least(now) } }) diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index 9bda53371..01e7fa5a1 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts @@ -427,6 +427,7 @@ async function completeVideoCheck ( expect(video.isLocal).to.equal(attributes.isLocal) expect(video.duration).to.equal(attributes.duration) expect(dateIsValid(video.createdAt)).to.be.true + expect(dateIsValid(video.publishedAt)).to.be.true expect(dateIsValid(video.updatedAt)).to.be.true const res = await getVideo(url, video.uuid) -- 2.41.0