Better tests for a better world
authorChocobozzz <florian.bigard@gmail.com>
Tue, 3 May 2016 19:03:51 +0000 (21:03 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Tue, 3 May 2016 19:03:51 +0000 (21:03 +0200)
server/tests/api/multiplePods.js
server/tests/api/singlePod.js
server/tests/api/users.js

index b6545ca60a6bb4d75270641f877f7590a150f425..ba4ce70c91d6c33eba5cc526e8951bff671ae8a5 100644 (file)
@@ -96,6 +96,12 @@ describe('Test multiple pods', function () {
               expect(video.podUrl).to.equal('http://localhost:9001')
               expect(video.magnetUri).to.exist
 
+              if (server.url !== 'http://localhost:9001') {
+                expect(video.isLocal).to.be.false
+              } else {
+                expect(video.isLocal).to.be.true
+              }
+
               // All pods should have the same magnet Uri
               if (base_magnet === null) {
                 base_magnet = video.magnetUri
@@ -139,6 +145,12 @@ describe('Test multiple pods', function () {
               expect(video.podUrl).to.equal('http://localhost:9002')
               expect(video.magnetUri).to.exist
 
+              if (server.url !== 'http://localhost:9002') {
+                expect(video.isLocal).to.be.false
+              } else {
+                expect(video.isLocal).to.be.true
+              }
+
               // All pods should have the same magnet Uri
               if (base_magnet === null) {
                 base_magnet = video.magnetUri
@@ -178,23 +190,31 @@ describe('Test multiple pods', function () {
               const videos = res.body
               expect(videos).to.be.an('array')
               expect(videos.length).to.equal(4)
-              let video = videos[2]
-              expect(video.name).to.equal('my super name for pod 3')
-              expect(video.description).to.equal('my super description for pod 3')
-              expect(video.podUrl).to.equal('http://localhost:9003')
-              expect(video.magnetUri).to.exist
-
-              video = videos[3]
-              expect(video.name).to.equal('my super name for pod 3-2')
-              expect(video.description).to.equal('my super description for pod 3-2')
-              expect(video.podUrl).to.equal('http://localhost:9003')
-              expect(video.magnetUri).to.exist
+              const video1 = videos[2]
+              expect(video1.name).to.equal('my super name for pod 3')
+              expect(video1.description).to.equal('my super description for pod 3')
+              expect(video1.podUrl).to.equal('http://localhost:9003')
+              expect(video1.magnetUri).to.exist
+
+              const video2 = videos[3]
+              expect(video2.name).to.equal('my super name for pod 3-2')
+              expect(video2.description).to.equal('my super description for pod 3-2')
+              expect(video2.podUrl).to.equal('http://localhost:9003')
+              expect(video2.magnetUri).to.exist
+
+              if (server.url !== 'http://localhost:9003') {
+                expect(video1.isLocal).to.be.false
+                expect(video2.isLocal).to.be.false
+              } else {
+                expect(video1.isLocal).to.be.true
+                expect(video2.isLocal).to.be.true
+              }
 
               // All pods should have the same magnet Uri
               if (base_magnet === null) {
-                base_magnet = video.magnetUri
+                base_magnet = video2.magnetUri
               } else {
-                expect(video.magnetUri).to.equal.magnetUri
+                expect(video2.magnetUri).to.equal.magnetUri
               }
 
               callback()
index 64d5475dd7b5c558ef128446614da7d9c986ac21..efd8a64bc7fd4e94708c2754fb36b056a9eb660b 100644 (file)
@@ -72,6 +72,8 @@ describe('Test a single pod', function () {
       expect(video.description).to.equal('my super description')
       expect(video.podUrl).to.equal('http://localhost:9001')
       expect(video.magnetUri).to.exist
+      expect(video.author).to.equal('root')
+      expect(video.isLocal).to.be.true
 
       video_id = video.id
 
@@ -97,6 +99,8 @@ describe('Test a single pod', function () {
       expect(video.description).to.equal('my super description')
       expect(video.podUrl).to.equal('http://localhost:9001')
       expect(video.magnetUri).to.exist
+      expect(video.author).to.equal('root')
+      expect(video.isLocal).to.be.true
 
       webtorrent.add(video.magnetUri, function (torrent) {
         expect(torrent.files).to.exist
@@ -119,6 +123,8 @@ describe('Test a single pod', function () {
       expect(video.name).to.equal('my super name')
       expect(video.description).to.equal('my super description')
       expect(video.podUrl).to.equal('http://localhost:9001')
+      expect(video.author).to.equal('root')
+      expect(video.isLocal).to.be.true
 
       done()
     })
index 2c97f75d4f52a24bc3c867e052ff1f8c17319ec7..e5395a79ffe9a0f349be64dca31d5d2598d75931 100644 (file)
@@ -98,7 +98,10 @@ describe('Test users', function () {
       utils.getVideosList(server.url, function (err, res) {
         if (err) throw err
 
-        video_id = res.body[0].id
+        const video = res.body[0]
+        expect(video.author).to.equal('root')
+
+        video_id = video.id
         done()
       })
     })