aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/multiplePods.js4
-rw-r--r--server/tests/api/singlePod.js3
-rw-r--r--server/tests/api/utils.js11
3 files changed, 18 insertions, 0 deletions
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 () {
98 expect(video.podUrl).to.equal('http://localhost:9001') 98 expect(video.podUrl).to.equal('http://localhost:9001')
99 expect(video.magnetUri).to.exist 99 expect(video.magnetUri).to.exist
100 expect(video.duration).to.equal(10) 100 expect(video.duration).to.equal(10)
101 expect(utils.dateIsValid(video.createdDate)).to.be.true
101 102
102 if (server.url !== 'http://localhost:9001') { 103 if (server.url !== 'http://localhost:9001') {
103 expect(video.isLocal).to.be.false 104 expect(video.isLocal).to.be.false
@@ -153,6 +154,7 @@ describe('Test multiple pods', function () {
153 expect(video.podUrl).to.equal('http://localhost:9002') 154 expect(video.podUrl).to.equal('http://localhost:9002')
154 expect(video.magnetUri).to.exist 155 expect(video.magnetUri).to.exist
155 expect(video.duration).to.equal(5) 156 expect(video.duration).to.equal(5)
157 expect(utils.dateIsValid(video.createdDate)).to.be.true
156 158
157 if (server.url !== 'http://localhost:9002') { 159 if (server.url !== 'http://localhost:9002') {
158 expect(video.isLocal).to.be.false 160 expect(video.isLocal).to.be.false
@@ -221,12 +223,14 @@ describe('Test multiple pods', function () {
221 expect(video1.podUrl).to.equal('http://localhost:9003') 223 expect(video1.podUrl).to.equal('http://localhost:9003')
222 expect(video1.magnetUri).to.exist 224 expect(video1.magnetUri).to.exist
223 expect(video1.duration).to.equal(5) 225 expect(video1.duration).to.equal(5)
226 expect(utils.dateIsValid(video1.createdDate)).to.be.true
224 227
225 expect(video2.name).to.equal('my super name for pod 3-2') 228 expect(video2.name).to.equal('my super name for pod 3-2')
226 expect(video2.description).to.equal('my super description for pod 3-2') 229 expect(video2.description).to.equal('my super description for pod 3-2')
227 expect(video2.podUrl).to.equal('http://localhost:9003') 230 expect(video2.podUrl).to.equal('http://localhost:9003')
228 expect(video2.magnetUri).to.exist 231 expect(video2.magnetUri).to.exist
229 expect(video2.duration).to.equal(5) 232 expect(video2.duration).to.equal(5)
233 expect(utils.dateIsValid(video2.createdDate)).to.be.true
230 234
231 if (server.url !== 'http://localhost:9003') { 235 if (server.url !== 'http://localhost:9003') {
232 expect(video1.isLocal).to.be.false 236 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 () {
76 expect(video.magnetUri).to.exist 76 expect(video.magnetUri).to.exist
77 expect(video.author).to.equal('root') 77 expect(video.author).to.equal('root')
78 expect(video.isLocal).to.be.true 78 expect(video.isLocal).to.be.true
79 expect(utils.dateIsValid(video.createdDate)).to.be.true
79 80
80 utils.testImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { 81 utils.testImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
81 if (err) throw err 82 if (err) throw err
@@ -109,6 +110,7 @@ describe('Test a single pod', function () {
109 expect(video.magnetUri).to.exist 110 expect(video.magnetUri).to.exist
110 expect(video.author).to.equal('root') 111 expect(video.author).to.equal('root')
111 expect(video.isLocal).to.be.true 112 expect(video.isLocal).to.be.true
113 expect(utils.dateIsValid(video.createdDate)).to.be.true
112 114
113 utils.testImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { 115 utils.testImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
114 if (err) throw err 116 if (err) throw err
@@ -138,6 +140,7 @@ describe('Test a single pod', function () {
138 expect(video.podUrl).to.equal('http://localhost:9001') 140 expect(video.podUrl).to.equal('http://localhost:9001')
139 expect(video.author).to.equal('root') 141 expect(video.author).to.equal('root')
140 expect(video.isLocal).to.be.true 142 expect(video.isLocal).to.be.true
143 expect(utils.dateIsValid(video.createdDate)).to.be.true
141 144
142 utils.testImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { 145 utils.testImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
143 if (err) throw err 146 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')
8const request = require('supertest') 8const request = require('supertest')
9 9
10const testUtils = { 10const testUtils = {
11 dateIsValid: dateIsValid,
11 flushTests: flushTests, 12 flushTests: flushTests,
12 getFriendsList: getFriendsList, 13 getFriendsList: getFriendsList,
13 getVideo: getVideo, 14 getVideo: getVideo,
@@ -28,6 +29,16 @@ const testUtils = {
28 29
29// ---------------------- Export functions -------------------- 30// ---------------------- Export functions --------------------
30 31
32function dateIsValid (dateString) {
33 const dateToCheck = new Date(dateString)
34 const now = new Date()
35
36 // Check if the interval is more than 2 minutes
37 if (now - dateToCheck > 120000) return false
38
39 return true
40}
41
31function flushTests (callback) { 42function flushTests (callback) {
32 exec('npm run clean:server:test', callback) 43 exec('npm run clean:server:test', callback)
33} 44}