diff --git a/test/category.js b/test/category.js index d8fe8062211981ae3d00d260ab84478a65a670e7..ac84fac4aec5c23433a9996a784ad70ff65e90af 100644 --- a/test/category.js +++ b/test/category.js @@ -18,7 +18,7 @@ describe('Categories', function() { }); }); }); - it('should try to create a new category', function(){ + it('should try to create a new category', function() { let testObject = { 'category_name': 'Terreiro', 'category_description': 'Lugar que mantém as tradições dos afrodescendentes', @@ -45,7 +45,7 @@ describe('Categories', function() { }); }); }); - it('should create a new category as admin', function(){ + it('should create a new category as admin', function() { let testObject = { 'email': 'abc@admin.com', 'password': 'admin', diff --git a/test/geolocation.js b/test/geolocation.js index 93b70df52c2006621be8a333fa98b4e811b19a2d..3808bac278c039843490a08189efd07f2d525e0d 100644 --- a/test/geolocation.js +++ b/test/geolocation.js @@ -3,16 +3,37 @@ var env = require('../enviroment'); const URL = env.URL; describe('Geolocation', function() { - it('should create a geolocation as an Android user', function() { + it('should create a geolocation as an android user', function() { + let credential = { + 'email': 'user@user.com', + 'password': 'user', + }; + return chakram.post(`${URL}end_users/login`, credential).then(function(loginResponse) { + let testObject = { + 'category_id': 1, + 'geolocation_name': env.randomWord(10), + 'latitude': 10.2123, + 'longitude': 112.2124214, + 'when_sent': new Date(Date.now()), + 'android_id': env.randomId(20), + 'user_id': loginResponse.body.result.userId, + 'description_location': env.randomWord(6, false, true) + ' ' + env.randomWord(6), + }; + return chakram.post(`${URL}geolocations`, testObject).then(function(myResponse) { + expect(myResponse).to.have.status(200); + expect(myResponse.body.result).to.be.a('object'); + }); + }); + }); + it('should create a geolocation as a logged user', function() { let testObject = { 'category_id': 1, 'geolocation_name': env.randomWord(10), - 'latitude': 10.2123, - 'longitude': 112.2124214, + 'latitude': 116.2123, + 'longitude': 50.2124214, 'when_sent': new Date(Date.now()), - 'android_id': env.randomId(20), 'description_location': env.randomWord(6, false, true) + ' ' + env.randomWord(6), - } + }; return chakram.post(`${URL}geolocations`, testObject).then(function(myResponse) { expect(myResponse).to.have.status(200); expect(myResponse.body.result).to.be.a('object'); @@ -33,4 +54,14 @@ describe('Geolocation', function() { }); }); }); + it('should try to remove one geolocation', function() { + return chakram.get(`${URL}geolocations`).then(function(myResponse) { + let id = myResponse.body.result[0].id; + return chakram.delete(`${URL}geolocations/${id}`).then(function(myResponse2) { + expect(myResponse2).to.have.status(401); + expect(myResponse2.body.error.code).to.contain('AUTHORIZATION_REQUIRED'); + }); + }); + }); }); +