aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-03-18 16:28:09 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-03-18 16:28:09 +0100
commit2df82d42cb57783cd90ccfc11fc8ffe4b95ebb70 (patch)
tree9c177f135a121ee34ed2e4f529dd2cacc3ad3f87 /server/tests/api
parentf0f5567b6918fc60c8cab15e13aec03a89a91dfb (diff)
downloadPeerTube-2df82d42cb57783cd90ccfc11fc8ffe4b95ebb70.tar.gz
PeerTube-2df82d42cb57783cd90ccfc11fc8ffe4b95ebb70.tar.zst
PeerTube-2df82d42cb57783cd90ccfc11fc8ffe4b95ebb70.zip
Change api output for videos
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/multiplePods.js14
-rw-r--r--server/tests/api/singlePod.js26
-rw-r--r--server/tests/api/utils.js12
3 files changed, 43 insertions, 9 deletions
diff --git a/server/tests/api/multiplePods.js b/server/tests/api/multiplePods.js
index e8b182622..0e2355a55 100644
--- a/server/tests/api/multiplePods.js
+++ b/server/tests/api/multiplePods.js
@@ -205,8 +205,8 @@ describe('Test multiple pods', function () {
205 if (err) throw err 205 if (err) throw err
206 206
207 const video = res.body[0] 207 const video = res.body[0]
208 to_remove.push(res.body[2]._id) 208 to_remove.push(res.body[2].id)
209 to_remove.push(res.body[3]._id) 209 to_remove.push(res.body[3].id)
210 210
211 webtorrent.add(video.magnetUri, function (torrent) { 211 webtorrent.add(video.magnetUri, function (torrent) {
212 expect(torrent.files).to.exist 212 expect(torrent.files).to.exist
@@ -300,11 +300,11 @@ describe('Test multiple pods', function () {
300 const videos = res.body 300 const videos = res.body
301 expect(videos).to.be.an('array') 301 expect(videos).to.be.an('array')
302 expect(videos.length).to.equal(2) 302 expect(videos.length).to.equal(2)
303 expect(videos[0]._id).not.to.equal(videos[1]._id) 303 expect(videos[0].id).not.to.equal(videos[1].id)
304 expect(videos[0]._id).not.to.equal(to_remove[0]) 304 expect(videos[0].id).not.to.equal(to_remove[0])
305 expect(videos[1]._id).not.to.equal(to_remove[0]) 305 expect(videos[1].id).not.to.equal(to_remove[0])
306 expect(videos[0]._id).not.to.equal(to_remove[1]) 306 expect(videos[0].id).not.to.equal(to_remove[1])
307 expect(videos[1]._id).not.to.equal(to_remove[1]) 307 expect(videos[1].id).not.to.equal(to_remove[1])
308 308
309 callback() 309 callback()
310 }) 310 })
diff --git a/server/tests/api/singlePod.js b/server/tests/api/singlePod.js
index 14f893f13..0b96f221a 100644
--- a/server/tests/api/singlePod.js
+++ b/server/tests/api/singlePod.js
@@ -68,7 +68,30 @@ describe('Test a single pod', function () {
68 expect(video.podUrl).to.equal('http://localhost:9001') 68 expect(video.podUrl).to.equal('http://localhost:9001')
69 expect(video.magnetUri).to.exist 69 expect(video.magnetUri).to.exist
70 70
71 video_id = video._id 71 video_id = video.id
72
73 webtorrent.add(video.magnetUri, function (torrent) {
74 expect(torrent.files).to.exist
75 expect(torrent.files.length).to.equal(1)
76 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
77
78 done()
79 })
80 })
81 })
82
83 it('Should get the video', function (done) {
84 // Yes, this could be long
85 this.timeout(60000)
86
87 utils.getVideo(url, video_id, function (err, res) {
88 if (err) throw err
89
90 const video = res.body
91 expect(video.name).to.equal('my super name')
92 expect(video.description).to.equal('my super description')
93 expect(video.podUrl).to.equal('http://localhost:9001')
94 expect(video.magnetUri).to.exist
72 95
73 webtorrent.add(video.magnetUri, function (torrent) { 96 webtorrent.add(video.magnetUri, function (torrent) {
74 expect(torrent.files).to.exist 97 expect(torrent.files).to.exist
@@ -91,7 +114,6 @@ describe('Test a single pod', function () {
91 expect(video.name).to.equal('my super name') 114 expect(video.name).to.equal('my super name')
92 expect(video.description).to.equal('my super description') 115 expect(video.description).to.equal('my super description')
93 expect(video.podUrl).to.equal('http://localhost:9001') 116 expect(video.podUrl).to.equal('http://localhost:9001')
94 expect(video.magnetUri).to.exist
95 117
96 done() 118 done()
97 }) 119 })
diff --git a/server/tests/api/utils.js b/server/tests/api/utils.js
index 05142085f..ea0982e81 100644
--- a/server/tests/api/utils.js
+++ b/server/tests/api/utils.js
@@ -9,6 +9,7 @@ const request = require('supertest')
9const testUtils = { 9const testUtils = {
10 flushTests: flushTests, 10 flushTests: flushTests,
11 getFriendsList: getFriendsList, 11 getFriendsList: getFriendsList,
12 getVideo: getVideo,
12 getVideosList: getVideosList, 13 getVideosList: getVideosList,
13 makeFriends: makeFriends, 14 makeFriends: makeFriends,
14 quitFriends: quitFriends, 15 quitFriends: quitFriends,
@@ -36,6 +37,17 @@ function getFriendsList (url, end) {
36 .end(end) 37 .end(end)
37} 38}
38 39
40function getVideo (url, id, end) {
41 const path = '/api/v1/videos/' + id
42
43 request(url)
44 .get(path)
45 .set('Accept', 'application/json')
46 .expect(200)
47 .expect('Content-Type', /json/)
48 .end(end)
49}
50
39function getVideosList (url, end) { 51function getVideosList (url, end) {
40 const path = '/api/v1/videos' 52 const path = '/api/v1/videos'
41 53