'use strict'
-var async = require('async')
-var chai = require('chai')
-var expect = chai.expect
-var pathUtils = require('path')
-var request = require('supertest')
+const async = require('async')
+const chai = require('chai')
+const expect = chai.expect
+const pathUtils = require('path')
+const request = require('supertest')
-var utils = require('./utils')
+const utils = require('./utils')
describe('Test parameters validator', function () {
- var app = null
- var url = ''
+ let app = null
+ let url = ''
function makePostRequest (path, fields, attach, done, fail) {
- var status_code = 400
+ let status_code = 400
if (fail !== undefined && fail === false) status_code = 200
- var req = request(url)
+ const req = request(url)
.post(path)
.set('Accept', 'application/json')
Object.keys(fields).forEach(function (field) {
- var value = fields[field]
+ const value = fields[field]
req.field(field, value)
})
}
function makePostBodyRequest (path, fields, done, fail) {
- var status_code = 400
+ let status_code = 400
if (fail !== undefined && fail === false) status_code = 200
request(url)
})
describe('Of the pods API', function () {
- var path = '/api/v1/pods/'
+ const path = '/api/v1/pods/'
describe('When adding a pod', function () {
it('Should fail with nothing', function (done) {
- var data = {}
+ const data = {}
makePostBodyRequest(path, data, done)
})
it('Should fail without public key', function (done) {
- var data = {
+ const data = {
data: {
url: 'http://coucou.com'
}
})
it('Should fail without an url', function (done) {
- var data = {
+ const data = {
data: {
publicKey: 'mysuperpublickey'
}
})
it('Should fail with an incorrect url', function (done) {
- var data = {
+ const data = {
data: {
url: 'coucou.com',
publicKey: 'mysuperpublickey'
})
it('Should succeed with the correct parameters', function (done) {
- var data = {
+ const data = {
data: {
url: 'http://coucou.com',
publicKey: 'mysuperpublickey'
})
describe('Of the videos API', function () {
- var path = '/api/v1/videos/'
+ const path = '/api/v1/videos/'
describe('When searching a video', function () {
it('Should fail with nothing', function (done) {
describe('When adding a video', function () {
it('Should fail with nothing', function (done) {
- var data = {}
- var attach = {}
+ const data = {}
+ const attach = {}
makePostRequest(path, data, attach, done)
})
it('Should fail without name', function (done) {
- var data = {
+ const data = {
description: 'my super description'
}
- var attach = {
- 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
+ const attach = {
+ 'videofile': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
}
makePostRequest(path, data, attach, done)
})
it('Should fail with a long name', function (done) {
- var data = {
+ const data = {
name: 'My very very very very very very very very very very very very very very very very long name',
description: 'my super description'
}
- var attach = {
- 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
+ const attach = {
+ 'videofile': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
}
makePostRequest(path, data, attach, done)
})
it('Should fail without description', function (done) {
- var data = {
+ const data = {
name: 'my super name'
}
- var attach = {
- 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
+ const attach = {
+ 'videofile': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
}
makePostRequest(path, data, attach, done)
})
it('Should fail with a long description', function (done) {
- var data = {
+ const data = {
name: 'my super name',
description: 'my super description which is very very very very very very very very very very very very very very' +
'very very very very very very very very very very very very very very very very very very very very very' +
'very very very very very very very very very very very very very very very long'
}
- var attach = {
- 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
+ const attach = {
+ 'videofile': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
}
makePostRequest(path, data, attach, done)
})
it('Should fail without an input file', function (done) {
- var data = {
+ const data = {
name: 'my super name',
description: 'my super description'
}
- var attach = {}
+ const attach = {}
makePostRequest(path, data, attach, done)
})
it('Should fail without an incorrect input file', function (done) {
- var data = {
+ const data = {
name: 'my super name',
description: 'my super description'
}
- var attach = {
- 'input_video': pathUtils.join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
+ const attach = {
+ 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
}
makePostRequest(path, data, attach, done)
})
it('Should succeed with the correct parameters', function (done) {
- var data = {
+ const data = {
name: 'my super name',
description: 'my super description'
}
- var attach = {
- 'input_video': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
+ const attach = {
+ 'videofile': pathUtils.join(__dirname, 'fixtures', 'video_short.webm')
}
makePostRequest(path, data, attach, function () {
- attach.input_video = pathUtils.join(__dirname, 'fixtures', 'video_short.mp4')
+ attach.videofile = pathUtils.join(__dirname, 'fixtures', 'video_short.mp4')
makePostRequest(path, data, attach, function () {
- attach.input_video = pathUtils.join(__dirname, 'fixtures', 'video_short.ogv')
+ attach.videofile = pathUtils.join(__dirname, 'fixtures', 'video_short.ogv')
makePostRequest(path, data, attach, done, true)
}, true)
}, true)
it('Should have 404 with nothing', function (done) {
request(url)
.delete(path)
- .expect(404, done)
+ .expect(400, done)
})
it('Should fail without a mongodb id', function (done) {