aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/singlePod.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/singlePod.js')
-rw-r--r--server/tests/api/singlePod.js64
1 files changed, 39 insertions, 25 deletions
diff --git a/server/tests/api/singlePod.js b/server/tests/api/singlePod.js
index 1a53ada3a..884a83032 100644
--- a/server/tests/api/singlePod.js
+++ b/server/tests/api/singlePod.js
@@ -47,8 +47,9 @@ describe('Test a single pod', function () {
47 utils.getVideosList(server.url, function (err, res) { 47 utils.getVideosList(server.url, function (err, res) {
48 if (err) throw err 48 if (err) throw err
49 49
50 expect(res.body).to.be.an('array') 50 expect(res.body.total).to.equal(0)
51 expect(res.body.length).to.equal(0) 51 expect(res.body.data).to.be.an('array')
52 expect(res.body.data.length).to.equal(0)
52 53
53 done() 54 done()
54 }) 55 })
@@ -66,13 +67,14 @@ describe('Test a single pod', function () {
66 utils.getVideosList(server.url, function (err, res) { 67 utils.getVideosList(server.url, function (err, res) {
67 if (err) throw err 68 if (err) throw err
68 69
69 expect(res.body).to.be.an('array') 70 expect(res.body.total).to.equal(1)
70 expect(res.body.length).to.equal(1) 71 expect(res.body.data).to.be.an('array')
72 expect(res.body.data.length).to.equal(1)
71 73
72 const video = res.body[0] 74 const video = res.body.data[0]
73 expect(video.name).to.equal('my super name') 75 expect(video.name).to.equal('my super name')
74 expect(video.description).to.equal('my super description') 76 expect(video.description).to.equal('my super description')
75 expect(video.podUrl).to.equal('http://localhost:9001') 77 expect(video.podUrl).to.equal('localhost:9001')
76 expect(video.magnetUri).to.exist 78 expect(video.magnetUri).to.exist
77 expect(video.author).to.equal('root') 79 expect(video.author).to.equal('root')
78 expect(video.isLocal).to.be.true 80 expect(video.isLocal).to.be.true
@@ -106,7 +108,7 @@ describe('Test a single pod', function () {
106 const video = res.body 108 const video = res.body
107 expect(video.name).to.equal('my super name') 109 expect(video.name).to.equal('my super name')
108 expect(video.description).to.equal('my super description') 110 expect(video.description).to.equal('my super description')
109 expect(video.podUrl).to.equal('http://localhost:9001') 111 expect(video.podUrl).to.equal('localhost:9001')
110 expect(video.magnetUri).to.exist 112 expect(video.magnetUri).to.exist
111 expect(video.author).to.equal('root') 113 expect(video.author).to.equal('root')
112 expect(video.isLocal).to.be.true 114 expect(video.isLocal).to.be.true
@@ -131,13 +133,14 @@ describe('Test a single pod', function () {
131 utils.searchVideo(server.url, 'my', function (err, res) { 133 utils.searchVideo(server.url, 'my', function (err, res) {
132 if (err) throw err 134 if (err) throw err
133 135
134 expect(res.body).to.be.an('array') 136 expect(res.body.total).to.equal(1)
135 expect(res.body.length).to.equal(1) 137 expect(res.body.data).to.be.an('array')
138 expect(res.body.data.length).to.equal(1)
136 139
137 const video = res.body[0] 140 const video = res.body.data[0]
138 expect(video.name).to.equal('my super name') 141 expect(video.name).to.equal('my super name')
139 expect(video.description).to.equal('my super description') 142 expect(video.description).to.equal('my super description')
140 expect(video.podUrl).to.equal('http://localhost:9001') 143 expect(video.podUrl).to.equal('localhost:9001')
141 expect(video.author).to.equal('root') 144 expect(video.author).to.equal('root')
142 expect(video.isLocal).to.be.true 145 expect(video.isLocal).to.be.true
143 expect(utils.dateIsValid(video.createdDate)).to.be.true 146 expect(utils.dateIsValid(video.createdDate)).to.be.true
@@ -155,8 +158,9 @@ describe('Test a single pod', function () {
155 utils.searchVideo(server.url, 'hello', function (err, res) { 158 utils.searchVideo(server.url, 'hello', function (err, res) {
156 if (err) throw err 159 if (err) throw err
157 160
158 expect(res.body).to.be.an('array') 161 expect(res.body.total).to.equal(0)
159 expect(res.body.length).to.equal(0) 162 expect(res.body.data).to.be.an('array')
163 expect(res.body.data.length).to.equal(0)
160 164
161 done() 165 done()
162 }) 166 })
@@ -179,8 +183,9 @@ describe('Test a single pod', function () {
179 utils.getVideosList(server.url, function (err, res) { 183 utils.getVideosList(server.url, function (err, res) {
180 if (err) throw err 184 if (err) throw err
181 185
182 expect(res.body).to.be.an('array') 186 expect(res.body.total).to.equal(0)
183 expect(res.body.length).to.equal(0) 187 expect(res.body.data).to.be.an('array')
188 expect(res.body.data.length).to.equal(0)
184 189
185 done() 190 done()
186 }) 191 })
@@ -201,7 +206,8 @@ describe('Test a single pod', function () {
201 utils.getVideosList(server.url, function (err, res) { 206 utils.getVideosList(server.url, function (err, res) {
202 if (err) throw err 207 if (err) throw err
203 208
204 const videos = res.body 209 expect(res.body.total).to.equal(6)
210 const videos = res.body.data
205 expect(videos).to.be.an('array') 211 expect(videos).to.be.an('array')
206 expect(videos.length).to.equal(6) 212 expect(videos.length).to.equal(6)
207 213
@@ -221,7 +227,7 @@ describe('Test a single pod', function () {
221 utils.getVideosList(server.url, function (err, res) { 227 utils.getVideosList(server.url, function (err, res) {
222 if (err) throw err 228 if (err) throw err
223 229
224 const videos = res.body 230 const videos = res.body.data
225 // For the next test 231 // For the next test
226 videosListBase = videos 232 videosListBase = videos
227 233
@@ -243,7 +249,8 @@ describe('Test a single pod', function () {
243 utils.getVideosListPagination(server.url, 0, 2, function (err, res) { 249 utils.getVideosListPagination(server.url, 0, 2, function (err, res) {
244 if (err) throw err 250 if (err) throw err
245 251
246 const videos = res.body 252 const videos = res.body.data
253 expect(res.body.total).to.equal(6)
247 expect(videos.length).to.equal(2) 254 expect(videos.length).to.equal(2)
248 expect(videos[0].name === videosListBase[0].name) 255 expect(videos[0].name === videosListBase[0].name)
249 expect(videos[1].name === videosListBase[1].name) 256 expect(videos[1].name === videosListBase[1].name)
@@ -256,7 +263,8 @@ describe('Test a single pod', function () {
256 utils.getVideosListPagination(server.url, 2, 3, function (err, res) { 263 utils.getVideosListPagination(server.url, 2, 3, function (err, res) {
257 if (err) throw err 264 if (err) throw err
258 265
259 const videos = res.body 266 const videos = res.body.data
267 expect(res.body.total).to.equal(6)
260 expect(videos.length).to.equal(4) 268 expect(videos.length).to.equal(4)
261 expect(videos[0].name === videosListBase[2].name) 269 expect(videos[0].name === videosListBase[2].name)
262 expect(videos[1].name === videosListBase[3].name) 270 expect(videos[1].name === videosListBase[3].name)
@@ -270,7 +278,8 @@ describe('Test a single pod', function () {
270 utils.getVideosListPagination(server.url, 5, 6, function (err, res) { 278 utils.getVideosListPagination(server.url, 5, 6, function (err, res) {
271 if (err) throw err 279 if (err) throw err
272 280
273 const videos = res.body 281 const videos = res.body.data
282 expect(res.body.total).to.equal(6)
274 expect(videos.length).to.equal(1) 283 expect(videos.length).to.equal(1)
275 expect(videos[0].name === videosListBase[5].name) 284 expect(videos[0].name === videosListBase[5].name)
276 285
@@ -282,7 +291,8 @@ describe('Test a single pod', function () {
282 utils.searchVideoWithPagination(server.url, 'webm', 0, 1, function (err, res) { 291 utils.searchVideoWithPagination(server.url, 'webm', 0, 1, function (err, res) {
283 if (err) throw err 292 if (err) throw err
284 293
285 const videos = res.body 294 const videos = res.body.data
295 expect(res.body.total).to.equal(4)
286 expect(videos.length).to.equal(1) 296 expect(videos.length).to.equal(1)
287 expect(videos[0].name === 'video_short.webm name') 297 expect(videos[0].name === 'video_short.webm name')
288 298
@@ -294,7 +304,8 @@ describe('Test a single pod', function () {
294 utils.searchVideoWithPagination(server.url, 'webm', 2, 2, function (err, res) { 304 utils.searchVideoWithPagination(server.url, 'webm', 2, 2, function (err, res) {
295 if (err) throw err 305 if (err) throw err
296 306
297 const videos = res.body 307 const videos = res.body.data
308 expect(res.body.total).to.equal(4)
298 expect(videos.length).to.equal(2) 309 expect(videos.length).to.equal(2)
299 expect(videos[0].name === 'video_short2.webm name') 310 expect(videos[0].name === 'video_short2.webm name')
300 expect(videos[1].name === 'video_short3.webm name') 311 expect(videos[1].name === 'video_short3.webm name')
@@ -307,7 +318,8 @@ describe('Test a single pod', function () {
307 utils.searchVideoWithPagination(server.url, 'webm', 0, 15, function (err, res) { 318 utils.searchVideoWithPagination(server.url, 'webm', 0, 15, function (err, res) {
308 if (err) throw err 319 if (err) throw err
309 320
310 const videos = res.body 321 const videos = res.body.data
322 expect(res.body.total).to.equal(4)
311 expect(videos.length).to.equal(4) 323 expect(videos.length).to.equal(4)
312 324
313 done() 325 done()
@@ -318,7 +330,8 @@ describe('Test a single pod', function () {
318 utils.getVideosListSort(server.url, '-name', function (err, res) { 330 utils.getVideosListSort(server.url, '-name', function (err, res) {
319 if (err) throw err 331 if (err) throw err
320 332
321 const videos = res.body 333 const videos = res.body.data
334 expect(res.body.total).to.equal(6)
322 expect(videos.length).to.equal(6) 335 expect(videos.length).to.equal(6)
323 expect(videos[5].name === 'video_short.mp4 name') 336 expect(videos[5].name === 'video_short.mp4 name')
324 expect(videos[4].name === 'video_short.ogv name') 337 expect(videos[4].name === 'video_short.ogv name')
@@ -335,7 +348,8 @@ describe('Test a single pod', function () {
335 utils.searchVideoWithSort(server.url, 'webm', 'name', function (err, res) { 348 utils.searchVideoWithSort(server.url, 'webm', 'name', function (err, res) {
336 if (err) throw err 349 if (err) throw err
337 350
338 const videos = res.body 351 const videos = res.body.data
352 expect(res.body.total).to.equal(4)
339 expect(videos.length).to.equal(4) 353 expect(videos.length).to.equal(4)
340 354
341 expect(videos[0].name === 'video_short.webm name') 355 expect(videos[0].name === 'video_short.webm name')