From 3a8a8b51228070d8e6a01ea6e460534aa0a20efc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 3 May 2016 22:41:46 +0200 Subject: Video duration support (server) --- server/tests/api/multiplePods.js | 5 +++++ server/tests/api/singlePod.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'server/tests') diff --git a/server/tests/api/multiplePods.js b/server/tests/api/multiplePods.js index ba4ce70c9..adc99f714 100644 --- a/server/tests/api/multiplePods.js +++ b/server/tests/api/multiplePods.js @@ -95,6 +95,7 @@ describe('Test multiple pods', function () { expect(video.description).to.equal('my super description for pod 1') expect(video.podUrl).to.equal('http://localhost:9001') expect(video.magnetUri).to.exist + expect(video.duration).to.equal(10) if (server.url !== 'http://localhost:9001') { expect(video.isLocal).to.be.false @@ -144,6 +145,7 @@ describe('Test multiple pods', function () { expect(video.description).to.equal('my super description for pod 2') expect(video.podUrl).to.equal('http://localhost:9002') expect(video.magnetUri).to.exist + expect(video.duration).to.equal(5) if (server.url !== 'http://localhost:9002') { expect(video.isLocal).to.be.false @@ -190,17 +192,20 @@ describe('Test multiple pods', function () { const videos = res.body expect(videos).to.be.an('array') expect(videos.length).to.equal(4) + 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 + expect(video1.duration).to.equal(5) 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 + expect(video2.duration).to.equal(5) if (server.url !== 'http://localhost:9003') { expect(video1.isLocal).to.be.false diff --git a/server/tests/api/singlePod.js b/server/tests/api/singlePod.js index efd8a64bc..e2999530e 100644 --- a/server/tests/api/singlePod.js +++ b/server/tests/api/singlePod.js @@ -4,6 +4,7 @@ const async = require('async') const chai = require('chai') const expect = chai.expect const fs = require('fs') +const keyBy = require('lodash/keyBy') const pathUtils = require('path') const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent')) @@ -165,6 +166,37 @@ describe('Test a single pod', function () { }) }) + it('Should upload 6 videos', function (done) { + this.timeout(25000) + const videos = [ + 'video_short.mp4', 'video_short.ogv', 'video_short.webm', + 'video_short1.webm', 'video_short2.webm', 'video_short3.webm' + ] + async.each(videos, function (video, callback_each) { + utils.uploadVideo(server.url, server.access_token, video + ' name', video + ' description', video, callback_each) + }, done) + }) + + it('Should have the correct durations', function (done) { + utils.getVideosList(server.url, function (err, res) { + if (err) throw err + + const videos = res.body + expect(videos).to.be.an('array') + expect(videos.length).to.equal(6) + + const videos_by_name = keyBy(videos, 'name') + expect(videos_by_name['video_short.mp4 name'].duration).to.equal(5) + expect(videos_by_name['video_short.ogv name'].duration).to.equal(5) + expect(videos_by_name['video_short.webm name'].duration).to.equal(5) + expect(videos_by_name['video_short1.webm name'].duration).to.equal(10) + expect(videos_by_name['video_short2.webm name'].duration).to.equal(5) + expect(videos_by_name['video_short3.webm name'].duration).to.equal(5) + + done() + }) + }) + after(function (done) { process.kill(-server.app.pid) process.kill(-webtorrent.app.pid) -- cgit v1.2.3