Skip to content
Snippets Groups Projects
Commit 0407732c authored by Henrique Varella Ehrenfried's avatar Henrique Varella Ehrenfried :speech_balloon:
Browse files

Add tests to geolocation and category

parent bf8b126d
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,7 @@ describe('Categories', function() { ...@@ -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 = { let testObject = {
'category_name': 'Terreiro', 'category_name': 'Terreiro',
'category_description': 'Lugar que mantém as tradições dos afrodescendentes', 'category_description': 'Lugar que mantém as tradições dos afrodescendentes',
...@@ -45,7 +45,7 @@ describe('Categories', function() { ...@@ -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 = { let testObject = {
'email': 'abc@admin.com', 'email': 'abc@admin.com',
'password': 'admin', 'password': 'admin',
......
...@@ -3,16 +3,37 @@ var env = require('../enviroment'); ...@@ -3,16 +3,37 @@ var env = require('../enviroment');
const URL = env.URL; const URL = env.URL;
describe('Geolocation', function() { 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 = { let testObject = {
'category_id': 1, 'category_id': 1,
'geolocation_name': env.randomWord(10), 'geolocation_name': env.randomWord(10),
'latitude': 10.2123, 'latitude': 116.2123,
'longitude': 112.2124214, 'longitude': 50.2124214,
'when_sent': new Date(Date.now()), 'when_sent': new Date(Date.now()),
'android_id': env.randomId(20),
'description_location': env.randomWord(6, false, true) + ' ' + env.randomWord(6), 'description_location': env.randomWord(6, false, true) + ' ' + env.randomWord(6),
} };
return chakram.post(`${URL}geolocations`, testObject).then(function(myResponse) { return chakram.post(`${URL}geolocations`, testObject).then(function(myResponse) {
expect(myResponse).to.have.status(200); expect(myResponse).to.have.status(200);
expect(myResponse.body.result).to.be.a('object'); expect(myResponse.body.result).to.be.a('object');
...@@ -33,4 +54,14 @@ describe('Geolocation', function() { ...@@ -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');
});
});
});
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment