[Ivan Diaz] - #8 - Change response to be function [skip ci]

This commit is contained in:
Ivan Diaz 2016-02-11 20:22:55 -03:00
parent 3c56dbbcb7
commit 2aceef847c
2 changed files with 23 additions and 7 deletions

View File

@ -2,9 +2,25 @@ module.exports = [
{ {
path: 'user/login', path: 'user/login',
time: 1000, time: 1000,
response: { response: function (data) {
let response;
if (data.password === 'invalid') {
response = {
status: 'fail',
message: 'Invalid Credientals'
};
} else {
response = {
status: 'success',
data: {
'userId': 12, 'userId': 12,
'token': 'cc6b4921e6733d6aafe284ec0d7be57e' 'token': 'cc6b4921e6733d6aafe284ec0d7be57e'
} }
} }
}
return response;
}
}
]; ];

View File

@ -7,9 +7,7 @@ let fixtures = (function () {
return { return {
add(fixtures) { add(fixtures) {
fixtures.forEach((fixture) => { fixturesData = fixturesData.concat(fixtures);
fixturesData.push(fixture);
});
}, },
getAll() { getAll() {
return fixturesData; return fixturesData;
@ -25,6 +23,8 @@ _.each(fixtures.getAll(), function (fixture) {
contentType: 'application/json', contentType: 'application/json',
url: 'http://localhost:3000/api/' + fixture.path, url: 'http://localhost:3000/api/' + fixture.path,
responseTime: fixture.time || 500, responseTime: fixture.time || 500,
responseText: fixture.response response: function (settings) {
this.responseText = fixture.response(settings.data)
}
}); });
}); });