describe('Of the pods API', function () {
const path = '/api/v1/pods/'
- describe('When adding a pod', function () {
- it('Should fail with nothing', function (done) {
- const data = {}
- requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
- })
-
- it('Should fail without public key', function (done) {
- const data = {
- url: 'http://coucou.com'
- }
- requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
- })
-
- it('Should fail without an url', function (done) {
- const data = {
- publicKey: 'mysuperpublickey'
- }
- requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
- })
-
- it('Should fail with an incorrect url', function (done) {
- const data = {
- url: 'coucou.com',
- publicKey: 'mysuperpublickey'
- }
- requestsUtils.makePostBodyRequest(server.url, path, null, data, function () {
- data.url = 'http://coucou'
- requestsUtils.makePostBodyRequest(server.url, path, null, data, function () {
- data.url = 'coucou'
- requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
- })
- })
- })
-
- it('Should succeed with the correct parameters', function (done) {
- const data = {
- url: 'http://coucou.com',
- publicKey: 'mysuperpublickey'
- }
- requestsUtils.makePostBodyRequest(server.url, path, null, data, done, 200)
- })
- })
-
- describe('For the friends API', function () {
+ describe('When making friends', function () {
let userAccessToken = null
before(function (done) {
it('Should fail without urls', function (done) {
request(server.url)
.post(path + '/makefriends')
- .set('Authorization', 'Bearer faketoken')
+ .set('Authorization', 'Bearer ' + server.accessToken)
.set('Accept', 'application/json')
- .expect(401, done)
+ .expect(400, done)
})
it('Should fail with urls is not an array', function (done) {
request(server.url)
.post(path + '/makefriends')
.send({ urls: 'http://localhost:9002' })
- .set('Authorization', 'Bearer faketoken')
+ .set('Authorization', 'Bearer ' + server.accessToken)
.set('Accept', 'application/json')
- .expect(401, done)
+ .expect(400, done)
})
it('Should fail if the array is not composed by urls', function (done) {
request(server.url)
.post(path + '/makefriends')
.send({ urls: [ 'http://localhost:9002', 'localhost:coucou' ] })
- .set('Authorization', 'Bearer faketoken')
+ .set('Authorization', 'Bearer ' + server.accessToken)
.set('Accept', 'application/json')
- .expect(401, done)
+ .expect(400, done)
+ })
+
+ it('Should fail if urls are not unique', function (done) {
+ request(server.url)
+ .post(path + '/makefriends')
+ .send({ urls: [ 'http://localhost:9002', 'http://localhost:9002' ] })
+ .set('Authorization', 'Bearer ' + server.accessToken)
+ .set('Accept', 'application/json')
+ .expect(400, done)
})
it('Should fail with a invalid token', function (done) {
})
})
})
+
+ describe('When adding a pod', function () {
+ it('Should fail with nothing', function (done) {
+ const data = {}
+ requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
+ })
+
+ it('Should fail without public key', function (done) {
+ const data = {
+ url: 'http://coucou.com'
+ }
+ requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
+ })
+
+ it('Should fail without an url', function (done) {
+ const data = {
+ publicKey: 'mysuperpublickey'
+ }
+ requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
+ })
+
+ it('Should fail with an incorrect url', function (done) {
+ const data = {
+ url: 'coucou.com',
+ publicKey: 'mysuperpublickey'
+ }
+ requestsUtils.makePostBodyRequest(server.url, path, null, data, function () {
+ data.url = 'http://coucou'
+ requestsUtils.makePostBodyRequest(server.url, path, null, data, function () {
+ data.url = 'coucou'
+ requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
+ })
+ })
+ })
+
+ it('Should succeed with the correct parameters', function (done) {
+ const data = {
+ url: 'http://coucou.com',
+ publicKey: 'mysuperpublickey'
+ }
+ requestsUtils.makePostBodyRequest(server.url, path, null, data, done, 200)
+ })
+ })
})
describe('Of the videos API', function () {