+/* eslint-disable no-unused-expressions */
+
'use strict'
const chai = require('chai')
it('Should fail without name', function (done) {
const data = {
+ category: 5,
+ licence: 1,
+ language: 6,
+ nsfw: false,
description: 'my super description',
tags: [ 'tag1', 'tag2' ]
}
it('Should fail with a long name', function (done) {
const data = {
name: 'My very very very very very very very very very very very very very very very very long name',
+ category: 5,
+ licence: 1,
+ language: 6,
+ nsfw: false,
description: 'my super description',
tags: [ 'tag1', 'tag2' ]
}
requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done)
})
- it('Should fail without description', function (done) {
+ it('Should fail without a category', function (done) {
const data = {
name: 'my super name',
+ licence: 1,
+ language: 6,
+ nsfw: false,
+ description: 'my super description',
tags: [ 'tag1', 'tag2' ]
}
const attach = {
requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done)
})
- it('Should fail with a long description', function (done) {
+ it('Should fail with a bad category', function (done) {
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',
+ category: 125,
+ licence: 1,
+ language: 6,
+ nsfw: false,
+ description: 'my super description',
tags: [ 'tag1', 'tag2' ]
}
const attach = {
requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done)
})
- it('Should fail without tags', function (done) {
+ it('Should fail without a licence', function (done) {
const data = {
name: 'my super name',
- description: 'my super description'
+ category: 5,
+ language: 6,
+ nsfw: false,
+ description: 'my super description',
+ tags: [ 'tag1', 'tag2' ]
}
const attach = {
'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm')
requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done)
})
- it('Should fail with too many tags', function (done) {
+ it('Should fail with a bad licence', function (done) {
const data = {
name: 'my super name',
+ category: 5,
+ licence: 125,
+ language: 6,
+ nsfw: false,
description: 'my super description',
- tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ]
+ tags: [ 'tag1', 'tag2' ]
}
const attach = {
'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm')
requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done)
})
- it('Should fail with not enough tags', function (done) {
+ it('Should fail with a bad language', function (done) {
const data = {
name: 'my super name',
+ category: 5,
+ licence: 4,
+ language: 563,
+ nsfw: false,
description: 'my super description',
- tags: [ ]
+ tags: [ 'tag1', 'tag2' ]
}
const attach = {
'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm')
requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done)
})
- it('Should fail with a tag length too low', function (done) {
+ it('Should fail without nsfw attribute', function (done) {
const data = {
name: 'my super name',
+ category: 5,
+ licence: 4,
+ language: 6,
description: 'my super description',
- tags: [ 'tag1', 't' ]
+ tags: [ 'tag1', 'tag2' ]
}
const attach = {
'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm')
requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done)
})
- it('Should fail with a tag length too big', function (done) {
+ it('Should fail with a bad nsfw attribue', function (done) {
const data = {
name: 'my super name',
+ category: 5,
+ licence: 4,
+ language: 6,
+ nsfw: 2,
description: 'my super description',
- tags: [ 'mysupertagtoolong', 'tag1' ]
+ tags: [ 'tag1', 'tag2' ]
+ }
+ const attach = {
+ 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm')
+ }
+ requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done)
+ })
+
+ it('Should fail without description', function (done) {
+ const data = {
+ name: 'my super name',
+ category: 5,
+ licence: 1,
+ language: 6,
+ nsfw: false,
+ tags: [ 'tag1', 'tag2' ]
+ }
+ const attach = {
+ 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm')
+ }
+ requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done)
+ })
+
+ it('Should fail with a long description', function (done) {
+ const data = {
+ name: 'my super name',
+ category: 5,
+ licence: 1,
+ language: 6,
+ nsfw: false,
+ 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',
+ tags: [ 'tag1', 'tag2' ]
+ }
+ const attach = {
+ 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm')
+ }
+ requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done)
+ })
+
+ it('Should fail with too many tags', function (done) {
+ const data = {
+ name: 'my super name',
+ category: 5,
+ licence: 1,
+ language: 6,
+ nsfw: false,
+ description: 'my super description',
+ tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ]
+ }
+ const attach = {
+ 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm')
+ }
+ requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done)
+ })
+
+ it('Should fail with a tag length too low', function (done) {
+ const data = {
+ name: 'my super name',
+ category: 5,
+ licence: 1,
+ language: 6,
+ nsfw: false,
+ description: 'my super description',
+ tags: [ 'tag1', 't' ]
}
const attach = {
'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm')
requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, done)
})
- it('Should fail with malformed tags', function (done) {
+ it('Should fail with a tag length too big', function (done) {
const data = {
name: 'my super name',
+ category: 5,
+ licence: 1,
+ language: 6,
+ nsfw: false,
description: 'my super description',
- tags: [ 'my tag' ]
+ tags: [ 'mysupertagtoolong', 'tag1' ]
}
const attach = {
'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm')
it('Should fail without an input file', function (done) {
const data = {
name: 'my super name',
+ category: 5,
+ licence: 1,
+ language: 6,
+ nsfw: false,
description: 'my super description',
tags: [ 'tag1', 'tag2' ]
}
it('Should fail without an incorrect input file', function (done) {
const data = {
name: 'my super name',
+ category: 5,
+ licence: 1,
+ language: 6,
+ nsfw: false,
description: 'my super description',
tags: [ 'tag1', 'tag2' ]
}
it('Should fail with a too big duration', function (done) {
const data = {
name: 'my super name',
+ category: 5,
+ licence: 1,
+ language: 6,
+ nsfw: false,
description: 'my super description',
tags: [ 'tag1', 'tag2' ]
}
})
it('Should succeed with the correct parameters', function (done) {
+ this.timeout(10000)
+
const data = {
name: 'my super name',
+ category: 5,
+ licence: 1,
+ language: 6,
+ nsfw: false,
description: 'my super description',
tags: [ 'tag1', 'tag2' ]
}
const attach = {
'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short.webm')
}
+
requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, function () {
attach.videofile = pathUtils.join(__dirname, '..', 'fixtures', 'video_short.mp4')
requestsUtils.makePostUploadRequest(server.url, path, server.accessToken, data, attach, function () {
it('Should fail without a valid uuid', function (done) {
const data = {
+ category: 5,
+ licence: 2,
+ language: 6,
+ nsfw: false,
description: 'my super description',
tags: [ 'tag1', 'tag2' ]
}
it('Should fail with an unknown id', function (done) {
const data = {
+ category: 5,
+ licence: 2,
+ language: 6,
+ nsfw: false,
description: 'my super description',
tags: [ 'tag1', 'tag2' ]
}
it('Should fail with a long name', function (done) {
const data = {
name: 'My very very very very very very very very very very very very very very very very long name',
+ category: 5,
+ licence: 2,
+ language: 6,
+ nsfw: false,
description: 'my super description',
tags: [ 'tag1', 'tag2' ]
}
requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
})
- it('Should fail with a long description', function (done) {
+ it('Should fail with a bad category', function (done) {
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',
+ category: 128,
+ licence: 2,
+ language: 6,
+ nsfw: false,
+ description: 'my super description',
tags: [ 'tag1', 'tag2' ]
}
requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
})
- it('Should fail with too many tags', function (done) {
+ it('Should fail with a bad licence', function (done) {
const data = {
name: 'my super name',
+ category: 5,
+ licence: 128,
+ language: 6,
+ nsfw: false,
description: 'my super description',
- tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ]
+ tags: [ 'tag1', 'tag2' ]
}
requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
})
- it('Should fail with not enough tags', function (done) {
+ it('Should fail with a bad language', function (done) {
const data = {
name: 'my super name',
+ category: 5,
+ licence: 3,
+ language: 896,
+ nsfw: false,
description: 'my super description',
- tags: [ ]
+ tags: [ 'tag1', 'tag2' ]
}
requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
})
- it('Should fail with a tag length too low', function (done) {
+ it('Should fail with a bad nsfw attribute', function (done) {
const data = {
name: 'my super name',
+ category: 5,
+ licence: 5,
+ language: 6,
+ nsfw: -4,
description: 'my super description',
- tags: [ 'tag1', 't' ]
+ tags: [ 'tag1', 'tag2' ]
}
requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
})
- it('Should fail with a tag length too big', function (done) {
+ it('Should fail with a long description', function (done) {
+ const data = {
+ name: 'my super name',
+ category: 5,
+ licence: 2,
+ language: 6,
+ nsfw: false,
+ 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',
+ tags: [ 'tag1', 'tag2' ]
+ }
+ requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
+ })
+
+ it('Should fail with too many tags', function (done) {
const data = {
name: 'my super name',
+ category: 5,
+ licence: 2,
+ language: 6,
+ nsfw: false,
description: 'my super description',
- tags: [ 'mysupertagtoolong', 'tag1' ]
+ tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ]
}
requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
})
- it('Should fail with malformed tags', function (done) {
+ it('Should fail with a tag length too low', function (done) {
const data = {
name: 'my super name',
+ category: 5,
+ licence: 2,
+ language: 6,
+ nsfw: false,
description: 'my super description',
- tags: [ 'my tag' ]
+ tags: [ 'tag1', 't' ]
+ }
+ requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
+ })
+
+ it('Should fail with a tag length too big', function (done) {
+ const data = {
+ name: 'my super name',
+ category: 5,
+ licence: 2,
+ language: 6,
+ nsfw: false,
+ description: 'my super description',
+ tags: [ 'mysupertagtoolong', 'tag1' ]
}
requestsUtils.makePutBodyRequest(server.url, path + videoId, server.accessToken, data, done)
})
it('Should succeed with the correct parameters')
})
+ describe('When rating a video', function () {
+ let videoId
+
+ before(function (done) {
+ videosUtils.getVideosList(server.url, function (err, res) {
+ if (err) throw err
+
+ videoId = res.body.data[0].id
+
+ return done()
+ })
+ })
+
+ it('Should fail without a valid uuid', function (done) {
+ const data = {
+ rating: 'like'
+ }
+ requestsUtils.makePutBodyRequest(server.url, path + 'blabla/rate', server.accessToken, data, done)
+ })
+
+ it('Should fail with an unknown id', function (done) {
+ const data = {
+ rating: 'like'
+ }
+ requestsUtils.makePutBodyRequest(server.url, path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate', server.accessToken, data, done, 404)
+ })
+
+ it('Should fail with a wrong rating', function (done) {
+ const data = {
+ rating: 'likes'
+ }
+ requestsUtils.makePutBodyRequest(server.url, path + videoId + '/rate', server.accessToken, data, done)
+ })
+
+ it('Should succeed with the correct parameters', function (done) {
+ const data = {
+ rating: 'like'
+ }
+ requestsUtils.makePutBodyRequest(server.url, path + videoId + '/rate', server.accessToken, data, done, 204)
+ })
+ })
+
describe('When removing a video', function () {
it('Should have 404 with nothing', function (done) {
request(server.url)