aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'tests/api')
-rw-r--r--tests/api/checkParams.js19
-rw-r--r--tests/api/multiplePods.js3
-rw-r--r--tests/api/singlePod.js5
-rw-r--r--tests/api/utils.js7
4 files changed, 19 insertions, 15 deletions
diff --git a/tests/api/checkParams.js b/tests/api/checkParams.js
index 11fc68ff9..8ce1bd476 100644
--- a/tests/api/checkParams.js
+++ b/tests/api/checkParams.js
@@ -4,6 +4,7 @@
4 var async = require('async') 4 var async = require('async')
5 var chai = require('chai') 5 var chai = require('chai')
6 var expect = chai.expect 6 var expect = chai.expect
7 var pathUtils = require('path')
7 var request = require('supertest') 8 var request = require('supertest')
8 9
9 var utils = require('./utils') 10 var utils = require('./utils')
@@ -119,7 +120,7 @@
119 describe('When searching a video', function () { 120 describe('When searching a video', function () {
120 it('Should fail with nothing', function (done) { 121 it('Should fail with nothing', function (done) {
121 request(url) 122 request(url)
122 .get(path + '/search/') 123 .get(pathUtils.join(path, 'search'))
123 .set('Accept', 'application/json') 124 .set('Accept', 'application/json')
124 .expect(400, done) 125 .expect(400, done)
125 }) 126 })
@@ -137,7 +138,7 @@
137 description: 'my super description' 138 description: 'my super description'
138 } 139 }
139 var attach = { 140 var attach = {
140 'input_video': __dirname + '/fixtures/video_short.webm' 141 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
141 } 142 }
142 makePostRequest(path, data, attach, done) 143 makePostRequest(path, data, attach, done)
143 }) 144 })
@@ -148,7 +149,7 @@
148 description: 'my super description' 149 description: 'my super description'
149 } 150 }
150 var attach = { 151 var attach = {
151 'input_video': __dirname + '/fixtures/video_short.webm' 152 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
152 } 153 }
153 makePostRequest(path, data, attach, done) 154 makePostRequest(path, data, attach, done)
154 }) 155 })
@@ -158,7 +159,7 @@
158 name: 'my super name' 159 name: 'my super name'
159 } 160 }
160 var attach = { 161 var attach = {
161 'input_video': __dirname + '/fixtures/video_short.webm' 162 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
162 } 163 }
163 makePostRequest(path, data, attach, done) 164 makePostRequest(path, data, attach, done)
164 }) 165 })
@@ -171,7 +172,7 @@
171 'very very very very very very very very very very very very very very very long' 172 'very very very very very very very very very very very very very very very long'
172 } 173 }
173 var attach = { 174 var attach = {
174 'input_video': __dirname + '/fixtures/video_short.webm' 175 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
175 } 176 }
176 makePostRequest(path, data, attach, done) 177 makePostRequest(path, data, attach, done)
177 }) 178 })
@@ -191,7 +192,7 @@
191 description: 'my super description' 192 description: 'my super description'
192 } 193 }
193 var attach = { 194 var attach = {
194 'input_video': __dirname + '/../fixtures/video_short_fake.webm' 195 'input_video': pathUtils.join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
195 } 196 }
196 makePostRequest(path, data, attach, done) 197 makePostRequest(path, data, attach, done)
197 }) 198 })
@@ -202,12 +203,12 @@
202 description: 'my super description' 203 description: 'my super description'
203 } 204 }
204 var attach = { 205 var attach = {
205 'input_video': __dirname + '/fixtures/video_short.webm' 206 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
206 } 207 }
207 makePostRequest(path, data, attach, function () { 208 makePostRequest(path, data, attach, function () {
208 attach.input_video = __dirname + '/fixtures/video_short.mp4' 209 attach.input_video = pathUtils.join(__dirname, 'fixtures', 'video_short.mp4')
209 makePostRequest(path, data, attach, function () { 210 makePostRequest(path, data, attach, function () {
210 attach.input_video = __dirname + '/fixtures/video_short.ogv' 211 attach.input_video = pathUtils.join(__dirname, 'fixtures', 'video_short.ogv')
211 makePostRequest(path, data, attach, done, true) 212 makePostRequest(path, data, attach, done, true)
212 }, true) 213 }, true)
213 }, true) 214 }, true)
diff --git a/tests/api/multiplePods.js b/tests/api/multiplePods.js
index 5070b450a..7949da80a 100644
--- a/tests/api/multiplePods.js
+++ b/tests/api/multiplePods.js
@@ -4,9 +4,10 @@
4 var async = require('async') 4 var async = require('async')
5 var chai = require('chai') 5 var chai = require('chai')
6 var expect = chai.expect 6 var expect = chai.expect
7 var pathUtils = require('path')
7 8
8 var utils = require('./utils') 9 var utils = require('./utils')
9 var webtorrent = require(__dirname + '/../../lib/webtorrent') 10 var webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
10 webtorrent.silent = true 11 webtorrent.silent = true
11 12
12 describe('Test multiple pods', function () { 13 describe('Test multiple pods', function () {
diff --git a/tests/api/singlePod.js b/tests/api/singlePod.js
index e5337256b..f33aa8c7a 100644
--- a/tests/api/singlePod.js
+++ b/tests/api/singlePod.js
@@ -5,8 +5,9 @@
5 var chai = require('chai') 5 var chai = require('chai')
6 var expect = chai.expect 6 var expect = chai.expect
7 var fs = require('fs') 7 var fs = require('fs')
8 var pathUtils = require('path')
8 9
9 var webtorrent = require(__dirname + '/../../lib/webtorrent') 10 var webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
10 webtorrent.silent = true 11 webtorrent.silent = true
11 12
12 var utils = require('./utils') 13 var utils = require('./utils')
@@ -112,7 +113,7 @@
112 utils.removeVideo(url, video_id, function (err) { 113 utils.removeVideo(url, video_id, function (err) {
113 if (err) throw err 114 if (err) throw err
114 115
115 fs.readdir(__dirname + '/../../test1/uploads/', function (err, files) { 116 fs.readdir(pathUtils.join(__dirname, '../../test1/uploads/'), function (err, files) {
116 if (err) throw err 117 if (err) throw err
117 118
118 expect(files.length).to.equal(0) 119 expect(files.length).to.equal(0)
diff --git a/tests/api/utils.js b/tests/api/utils.js
index a1996b4d7..b71e943ed 100644
--- a/tests/api/utils.js
+++ b/tests/api/utils.js
@@ -4,6 +4,7 @@
4 var child_process = require('child_process') 4 var child_process = require('child_process')
5 var exec = child_process.exec 5 var exec = child_process.exec
6 var fork = child_process.fork 6 var fork = child_process.fork
7 var pathUtils = require('path')
7 var request = require('supertest') 8 var request = require('supertest')
8 9
9 var testUtils = { 10 var testUtils = {
@@ -22,7 +23,7 @@
22 // ---------------------- Export functions -------------------- 23 // ---------------------- Export functions --------------------
23 24
24 function flushTests (callback) { 25 function flushTests (callback) {
25 exec(__dirname + '/../../scripts/clean_test.sh', callback) 26 exec(pathUtils.join(__dirname, '../../scripts/clean_test.sh'), callback)
26 } 27 }
27 28
28 function getFriendsList (url, end) { 29 function getFriendsList (url, end) {
@@ -139,7 +140,7 @@
139 detached: true 140 detached: true
140 } 141 }
141 142
142 var app = fork(__dirname + '/../../server.js', [], options) 143 var app = fork(pathUtils.join(__dirname, '../../server.js'), [], options)
143 app.stdout.on('data', function onStdout (data) { 144 app.stdout.on('data', function onStdout (data) {
144 var dont_continue = false 145 var dont_continue = false
145 // Check if all required sentences are here 146 // Check if all required sentences are here
@@ -175,7 +176,7 @@
175 .set('Accept', 'application/json') 176 .set('Accept', 'application/json')
176 .field('name', name) 177 .field('name', name)
177 .field('description', description) 178 .field('description', description)
178 .attach('input_video', __dirname + '/fixtures/' + fixture) 179 .attach('input_video', pathUtils.join(__dirname, 'fixtures', fixture))
179 .expect(201) 180 .expect(201)
180 .end(end) 181 .end(end)
181 } 182 }