From bb10240ee15d31a1cc17c0e3d748dde817e7d0cb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 13 May 2016 20:42:11 +0200 Subject: Add createdDate to videos --- server/tests/api/multiplePods.js | 4 ++++ server/tests/api/singlePod.js | 3 +++ server/tests/api/utils.js | 11 +++++++++++ 3 files changed, 18 insertions(+) (limited to 'server/tests') diff --git a/server/tests/api/multiplePods.js b/server/tests/api/multiplePods.js index 51e7fb3d1..c31c18b02 100644 --- a/server/tests/api/multiplePods.js +++ b/server/tests/api/multiplePods.js @@ -98,6 +98,7 @@ describe('Test multiple pods', function () { expect(video.podUrl).to.equal('http://localhost:9001') expect(video.magnetUri).to.exist expect(video.duration).to.equal(10) + expect(utils.dateIsValid(video.createdDate)).to.be.true if (server.url !== 'http://localhost:9001') { expect(video.isLocal).to.be.false @@ -153,6 +154,7 @@ describe('Test multiple pods', function () { expect(video.podUrl).to.equal('http://localhost:9002') expect(video.magnetUri).to.exist expect(video.duration).to.equal(5) + expect(utils.dateIsValid(video.createdDate)).to.be.true if (server.url !== 'http://localhost:9002') { expect(video.isLocal).to.be.false @@ -221,12 +223,14 @@ describe('Test multiple pods', function () { expect(video1.podUrl).to.equal('http://localhost:9003') expect(video1.magnetUri).to.exist expect(video1.duration).to.equal(5) + expect(utils.dateIsValid(video1.createdDate)).to.be.true expect(video2.name).to.equal('my super name for pod 3-2') expect(video2.description).to.equal('my super description for pod 3-2') expect(video2.podUrl).to.equal('http://localhost:9003') expect(video2.magnetUri).to.exist expect(video2.duration).to.equal(5) + expect(utils.dateIsValid(video2.createdDate)).to.be.true if (server.url !== 'http://localhost:9003') { expect(video1.isLocal).to.be.false diff --git a/server/tests/api/singlePod.js b/server/tests/api/singlePod.js index d377bdf45..72002b631 100644 --- a/server/tests/api/singlePod.js +++ b/server/tests/api/singlePod.js @@ -76,6 +76,7 @@ describe('Test a single pod', function () { expect(video.magnetUri).to.exist expect(video.author).to.equal('root') expect(video.isLocal).to.be.true + expect(utils.dateIsValid(video.createdDate)).to.be.true utils.testImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { if (err) throw err @@ -109,6 +110,7 @@ describe('Test a single pod', function () { expect(video.magnetUri).to.exist expect(video.author).to.equal('root') expect(video.isLocal).to.be.true + expect(utils.dateIsValid(video.createdDate)).to.be.true utils.testImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { if (err) throw err @@ -138,6 +140,7 @@ describe('Test a single pod', function () { expect(video.podUrl).to.equal('http://localhost:9001') expect(video.author).to.equal('root') expect(video.isLocal).to.be.true + expect(utils.dateIsValid(video.createdDate)).to.be.true utils.testImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { if (err) throw err diff --git a/server/tests/api/utils.js b/server/tests/api/utils.js index f0b1c3653..d505cb5d9 100644 --- a/server/tests/api/utils.js +++ b/server/tests/api/utils.js @@ -8,6 +8,7 @@ const pathUtils = require('path') const request = require('supertest') const testUtils = { + dateIsValid: dateIsValid, flushTests: flushTests, getFriendsList: getFriendsList, getVideo: getVideo, @@ -28,6 +29,16 @@ const testUtils = { // ---------------------- Export functions -------------------- +function dateIsValid (dateString) { + const dateToCheck = new Date(dateString) + const now = new Date() + + // Check if the interval is more than 2 minutes + if (now - dateToCheck > 120000) return false + + return true +} + function flushTests (callback) { exec('npm run clean:server:test', callback) } -- cgit v1.2.3