mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-26 23:34:56 +02:00
[Ivan Diaz] - #8 - Change response to be function [skip ci]
This commit is contained in:
parent
3c56dbbcb7
commit
2aceef847c
@ -2,9 +2,25 @@ module.exports = [
|
||||
{
|
||||
path: 'user/login',
|
||||
time: 1000,
|
||||
response: {
|
||||
'userId': 12,
|
||||
'token': 'cc6b4921e6733d6aafe284ec0d7be57e'
|
||||
response: function (data) {
|
||||
let response;
|
||||
|
||||
if (data.password === 'invalid') {
|
||||
response = {
|
||||
status: 'fail',
|
||||
message: 'Invalid Credientals'
|
||||
};
|
||||
} else {
|
||||
response = {
|
||||
status: 'success',
|
||||
data: {
|
||||
'userId': 12,
|
||||
'token': 'cc6b4921e6733d6aafe284ec0d7be57e'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
];
|
||||
|
@ -7,9 +7,7 @@ let fixtures = (function () {
|
||||
|
||||
return {
|
||||
add(fixtures) {
|
||||
fixtures.forEach((fixture) => {
|
||||
fixturesData.push(fixture);
|
||||
});
|
||||
fixturesData = fixturesData.concat(fixtures);
|
||||
},
|
||||
getAll() {
|
||||
return fixturesData;
|
||||
@ -25,6 +23,8 @@ _.each(fixtures.getAll(), function (fixture) {
|
||||
contentType: 'application/json',
|
||||
url: 'http://localhost:3000/api/' + fixture.path,
|
||||
responseTime: fixture.time || 500,
|
||||
responseText: fixture.response
|
||||
response: function (settings) {
|
||||
this.responseText = fixture.response(settings.data)
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user