From 6d8ada5f24b245d3c84d29d65013f5315cbeff27 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 3 May 2016 21:03:51 +0200 Subject: [PATCH] Better tests for a better world --- server/tests/api/multiplePods.js | 46 +++++++++++++++++++++++--------- server/tests/api/singlePod.js | 6 +++++ server/tests/api/users.js | 5 +++- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/server/tests/api/multiplePods.js b/server/tests/api/multiplePods.js index b6545ca60..ba4ce70c9 100644 --- a/server/tests/api/multiplePods.js +++ b/server/tests/api/multiplePods.js @@ -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() diff --git a/server/tests/api/singlePod.js b/server/tests/api/singlePod.js index 64d5475dd..efd8a64bc 100644 --- a/server/tests/api/singlePod.js +++ b/server/tests/api/singlePod.js @@ -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() }) diff --git a/server/tests/api/users.js b/server/tests/api/users.js index 2c97f75d4..e5395a79f 100644 --- a/server/tests/api/users.js +++ b/server/tests/api/users.js @@ -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() }) }) -- 2.25.1