aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/singlePod.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-13 18:10:46 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-13 18:10:46 +0200
commitfbf1134e3e6b386c9ec5a3946c61f3faf84397fb (patch)
tree9071ea72c86e83bb07d8ec681a54daff2e0eb7b9 /server/tests/api/singlePod.js
parentf67e976fdccbfe6432c1176148d194c980a5585a (diff)
downloadPeerTube-fbf1134e3e6b386c9ec5a3946c61f3faf84397fb.tar.gz
PeerTube-fbf1134e3e6b386c9ec5a3946c61f3faf84397fb.tar.zst
PeerTube-fbf1134e3e6b386c9ec5a3946c61f3faf84397fb.zip
Introduce paginations in videos listing
Diffstat (limited to 'server/tests/api/singlePod.js')
-rw-r--r--server/tests/api/singlePod.js80
1 files changed, 80 insertions, 0 deletions
diff --git a/server/tests/api/singlePod.js b/server/tests/api/singlePod.js
index 0d0e6a82e..d377bdf45 100644
--- a/server/tests/api/singlePod.js
+++ b/server/tests/api/singlePod.js
@@ -15,6 +15,7 @@ const utils = require('./utils')
15describe('Test a single pod', function () { 15describe('Test a single pod', function () {
16 let server = null 16 let server = null
17 let videoId = -1 17 let videoId = -1
18 let videosListBase = null
18 19
19 before(function (done) { 20 before(function (done) {
20 this.timeout(20000) 21 this.timeout(20000)
@@ -215,7 +216,11 @@ describe('Test a single pod', function () {
215 216
216 it('Should have the correct thumbnails', function (done) { 217 it('Should have the correct thumbnails', function (done) {
217 utils.getVideosList(server.url, function (err, res) { 218 utils.getVideosList(server.url, function (err, res) {
219 if (err) throw err
220
218 const videos = res.body 221 const videos = res.body
222 // For the next test
223 videosListBase = videos
219 224
220 async.each(videos, function (video, callbackEach) { 225 async.each(videos, function (video, callbackEach) {
221 if (err) throw err 226 if (err) throw err
@@ -231,6 +236,81 @@ describe('Test a single pod', function () {
231 }) 236 })
232 }) 237 })
233 238
239 it('Should list only the two first videos', function (done) {
240 utils.getVideosListPagination(server.url, 0, 2, function (err, res) {
241 if (err) throw err
242
243 const videos = res.body
244 expect(videos.length).to.equal(2)
245 expect(videos[0].name === videosListBase[0].name)
246 expect(videos[1].name === videosListBase[1].name)
247
248 done()
249 })
250 })
251
252 it('Should list only the next three videos', function (done) {
253 utils.getVideosListPagination(server.url, 2, 3, function (err, res) {
254 if (err) throw err
255
256 const videos = res.body
257 expect(videos.length).to.equal(4)
258 expect(videos[0].name === videosListBase[2].name)
259 expect(videos[1].name === videosListBase[3].name)
260 expect(videos[2].name === videosListBase[4].name)
261
262 done()
263 })
264 })
265
266 it('Should list the last video', function (done) {
267 utils.getVideosListPagination(server.url, 5, 6, function (err, res) {
268 if (err) throw err
269
270 const videos = res.body
271 expect(videos.length).to.equal(1)
272 expect(videos[0].name === videosListBase[5].name)
273
274 done()
275 })
276 })
277
278 it('Should search the first video', function (done) {
279 utils.searchVideoWithPagination(server.url, 'webm', 0, 1, function (err, res) {
280 if (err) throw err
281
282 const videos = res.body
283 expect(videos.length).to.equal(1)
284 expect(videos[0].name === 'video_short.webm name')
285
286 done()
287 })
288 })
289
290 it('Should search the last two videos', function (done) {
291 utils.searchVideoWithPagination(server.url, 'webm', 2, 2, function (err, res) {
292 if (err) throw err
293
294 const videos = res.body
295 expect(videos.length).to.equal(2)
296 expect(videos[0].name === 'video_short2.webm name')
297 expect(videos[1].name === 'video_short3.webm name')
298
299 done()
300 })
301 })
302
303 it('Should search all the videos', function (done) {
304 utils.searchVideoWithPagination(server.url, 'webm', 0, 15, function (err, res) {
305 if (err) throw err
306
307 const videos = res.body
308 expect(videos.length).to.equal(4)
309
310 done()
311 })
312 })
313
234 after(function (done) { 314 after(function (done) {
235 process.kill(-server.app.pid) 315 process.kill(-server.app.pid)
236 process.kill(-webtorrent.app.pid) 316 process.kill(-webtorrent.app.pid)