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
1 merge request!1Acl testing
...@@ -3,7 +3,12 @@ var env = require('../enviroment'); ...@@ -3,7 +3,12 @@ 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 = { let testObject = {
'category_id': 1, 'category_id': 1,
'geolocation_name': env.randomWord(10), 'geolocation_name': env.randomWord(10),
...@@ -11,8 +16,24 @@ describe('Geolocation', function() { ...@@ -11,8 +16,24 @@ describe('Geolocation', function() {
'longitude': 112.2124214, 'longitude': 112.2124214,
'when_sent': new Date(Date.now()), 'when_sent': new Date(Date.now()),
'android_id': env.randomId(20), 'android_id': env.randomId(20),
'user_id': loginResponse.body.result.userId,
'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) {
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': 116.2123,
'longitude': 50.2124214,
'when_sent': new Date(Date.now()),
'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.
Please register or to comment