diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/multiple-pods.js | 5 | ||||
-rw-r--r-- | server/tests/api/single-pod.js | 8 | ||||
-rw-r--r-- | server/tests/utils/miscs.js | 6 |
3 files changed, 17 insertions, 2 deletions
diff --git a/server/tests/api/multiple-pods.js b/server/tests/api/multiple-pods.js index 672187068..4442a7ff7 100644 --- a/server/tests/api/multiple-pods.js +++ b/server/tests/api/multiple-pods.js | |||
@@ -105,6 +105,7 @@ describe('Test multiple pods', function () { | |||
105 | expect(video.duration).to.equal(10) | 105 | expect(video.duration).to.equal(10) |
106 | expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ]) | 106 | expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ]) |
107 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true | 107 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true |
108 | expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true | ||
108 | expect(video.author).to.equal('root') | 109 | expect(video.author).to.equal('root') |
109 | 110 | ||
110 | if (server.url !== 'http://localhost:9001') { | 111 | if (server.url !== 'http://localhost:9001') { |
@@ -167,6 +168,7 @@ describe('Test multiple pods', function () { | |||
167 | expect(video.duration).to.equal(5) | 168 | expect(video.duration).to.equal(5) |
168 | expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ]) | 169 | expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ]) |
169 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true | 170 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true |
171 | expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true | ||
170 | expect(video.author).to.equal('root') | 172 | expect(video.author).to.equal('root') |
171 | 173 | ||
172 | if (server.url !== 'http://localhost:9002') { | 174 | if (server.url !== 'http://localhost:9002') { |
@@ -247,6 +249,7 @@ describe('Test multiple pods', function () { | |||
247 | expect(video1.tags).to.deep.equal([ 'tag1p3' ]) | 249 | expect(video1.tags).to.deep.equal([ 'tag1p3' ]) |
248 | expect(video1.author).to.equal('root') | 250 | expect(video1.author).to.equal('root') |
249 | expect(miscsUtils.dateIsValid(video1.createdAt)).to.be.true | 251 | expect(miscsUtils.dateIsValid(video1.createdAt)).to.be.true |
252 | expect(miscsUtils.dateIsValid(video1.updatedAt)).to.be.true | ||
250 | 253 | ||
251 | expect(video2.name).to.equal('my super name for pod 3-2') | 254 | expect(video2.name).to.equal('my super name for pod 3-2') |
252 | expect(video2.description).to.equal('my super description for pod 3-2') | 255 | expect(video2.description).to.equal('my super description for pod 3-2') |
@@ -256,6 +259,7 @@ describe('Test multiple pods', function () { | |||
256 | expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ]) | 259 | expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ]) |
257 | expect(video2.author).to.equal('root') | 260 | expect(video2.author).to.equal('root') |
258 | expect(miscsUtils.dateIsValid(video2.createdAt)).to.be.true | 261 | expect(miscsUtils.dateIsValid(video2.createdAt)).to.be.true |
262 | expect(miscsUtils.dateIsValid(video2.updatedAt)).to.be.true | ||
259 | 263 | ||
260 | if (server.url !== 'http://localhost:9003') { | 264 | if (server.url !== 'http://localhost:9003') { |
261 | expect(video1.isLocal).to.be.false | 265 | expect(video1.isLocal).to.be.false |
@@ -398,6 +402,7 @@ describe('Test multiple pods', function () { | |||
398 | expect(!!videoUpdated).to.be.true | 402 | expect(!!videoUpdated).to.be.true |
399 | expect(videoUpdated.description).to.equal('my super description updated') | 403 | expect(videoUpdated.description).to.equal('my super description updated') |
400 | expect(videoUpdated.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) | 404 | expect(videoUpdated.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) |
405 | expect(miscsUtils.dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true | ||
401 | 406 | ||
402 | callback() | 407 | callback() |
403 | }) | 408 | }) |
diff --git a/server/tests/api/single-pod.js b/server/tests/api/single-pod.js index 57146900d..29512dfc6 100644 --- a/server/tests/api/single-pod.js +++ b/server/tests/api/single-pod.js | |||
@@ -83,6 +83,7 @@ describe('Test a single pod', function () { | |||
83 | expect(video.isLocal).to.be.true | 83 | expect(video.isLocal).to.be.true |
84 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | 84 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) |
85 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true | 85 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true |
86 | expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true | ||
86 | 87 | ||
87 | videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { | 88 | videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { |
88 | if (err) throw err | 89 | if (err) throw err |
@@ -117,6 +118,7 @@ describe('Test a single pod', function () { | |||
117 | expect(video.isLocal).to.be.true | 118 | expect(video.isLocal).to.be.true |
118 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | 119 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) |
119 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true | 120 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true |
121 | expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true | ||
120 | 122 | ||
121 | videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { | 123 | videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { |
122 | if (err) throw err | 124 | if (err) throw err |
@@ -143,6 +145,7 @@ describe('Test a single pod', function () { | |||
143 | expect(video.isLocal).to.be.true | 145 | expect(video.isLocal).to.be.true |
144 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | 146 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) |
145 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true | 147 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true |
148 | expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true | ||
146 | 149 | ||
147 | videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { | 150 | videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { |
148 | if (err) throw err | 151 | if (err) throw err |
@@ -170,6 +173,7 @@ describe('Test a single pod', function () { | |||
170 | // expect(video.isLocal).to.be.true | 173 | // expect(video.isLocal).to.be.true |
171 | // expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | 174 | // expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) |
172 | // expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true | 175 | // expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true |
176 | // expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true | ||
173 | 177 | ||
174 | // videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { | 178 | // videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { |
175 | // if (err) throw err | 179 | // if (err) throw err |
@@ -196,6 +200,7 @@ describe('Test a single pod', function () { | |||
196 | expect(video.isLocal).to.be.true | 200 | expect(video.isLocal).to.be.true |
197 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | 201 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) |
198 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true | 202 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true |
203 | expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true | ||
199 | 204 | ||
200 | videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { | 205 | videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) { |
201 | if (err) throw err | 206 | if (err) throw err |
@@ -522,6 +527,7 @@ describe('Test a single pod', function () { | |||
522 | expect(video.isLocal).to.be.true | 527 | expect(video.isLocal).to.be.true |
523 | expect(video.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) | 528 | expect(video.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) |
524 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true | 529 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true |
530 | expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true | ||
525 | 531 | ||
526 | done() | 532 | done() |
527 | }) | 533 | }) |
@@ -545,6 +551,7 @@ describe('Test a single pod', function () { | |||
545 | expect(video.isLocal).to.be.true | 551 | expect(video.isLocal).to.be.true |
546 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ]) | 552 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ]) |
547 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true | 553 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true |
554 | expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true | ||
548 | 555 | ||
549 | done() | 556 | done() |
550 | }) | 557 | }) |
@@ -569,6 +576,7 @@ describe('Test a single pod', function () { | |||
569 | expect(video.isLocal).to.be.true | 576 | expect(video.isLocal).to.be.true |
570 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ]) | 577 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ]) |
571 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true | 578 | expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true |
579 | expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true | ||
572 | 580 | ||
573 | done() | 581 | done() |
574 | }) | 582 | }) |
diff --git a/server/tests/utils/miscs.js b/server/tests/utils/miscs.js index 4ceff65df..c4b661496 100644 --- a/server/tests/utils/miscs.js +++ b/server/tests/utils/miscs.js | |||
@@ -6,12 +6,14 @@ const miscsUtils = { | |||
6 | 6 | ||
7 | // ---------------------- Export functions -------------------- | 7 | // ---------------------- Export functions -------------------- |
8 | 8 | ||
9 | function dateIsValid (dateString) { | 9 | function dateIsValid (dateString, interval) { |
10 | const dateToCheck = new Date(dateString) | 10 | const dateToCheck = new Date(dateString) |
11 | const now = new Date() | 11 | const now = new Date() |
12 | 12 | ||
13 | // Check if the interval is more than 2 minutes | 13 | // Check if the interval is more than 2 minutes |
14 | if (now - dateToCheck > 120000) return false | 14 | if (!interval) interval = 120000 |
15 | |||
16 | if (now - dateToCheck > interval) return false | ||
15 | 17 | ||
16 | return true | 18 | return true |
17 | } | 19 | } |