Skip to content

Commit

Permalink
Use status instead of code property (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
DevSide authored Feb 13, 2018
1 parent fd535b0 commit 68df77e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ module.exports = [
*/
post: function (match, data) {
return {
code: 201
       status: 201
};
}
},
Expand Down
22 changes: 11 additions & 11 deletions tests/support/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ module.exports = [
return 'Fixture !';
},
get: function (match, data) {
return {match: match, data: data, code: 200, status: 200};
return {match: match, data: data, status: 200};
},
post: function (match, data) {
return {match: match, data: data, code: 201, status: 201};
return {match: match, data: data, status: 201};
},
put: function (match, data) {
return {match: match, data: data, code: 201, status: 201};
return {match: match, data: data, status: 201};
}
},
{
Expand Down Expand Up @@ -93,10 +93,10 @@ module.exports = [
{
pattern: 'https://error.example/(\\w+)',
fixtures: function (match) {
var code = Number((match || [])[1]) || 404;
var newErr = new Error(Number(code));
newErr.response = http.STATUS_CODES[code];
newErr.status = code;
var status = Number((match || [])[1]) || 404;
var newErr = new Error(Number(status));
newErr.response = http.STATUS_CODES[status];
newErr.status = status;
throw newErr;
},
get: function (match, data) {
Expand All @@ -113,10 +113,10 @@ module.exports = [
pattern: 'https://validation.example',
fixtures: function (match, params, headers) {
var error = new Error( 422 );
var code = (match || [])[1] || 422;
var newErr = new Error(Number(code));
newErr.response = http.STATUS_CODES[code];
newErr.status = code;
var status = (match || [])[1] || 422;
var newErr = new Error(Number(status));
newErr.response = http.STATUS_CODES[status];
newErr.status = status;
newErr.responseHeader = 'application/json';
newErr.responseText = '{"password": "missing"}';
newErr.responseBody = { password: 'missing' };
Expand Down
6 changes: 3 additions & 3 deletions tests/support/expectations.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = function (request, config, isServer) {
expect(!err).toBe(true);
expect(result.match[1]).toBe('666');
expect(result.data).toBe('Fixture !');
expect(result.code).toBe(200);
expect(result.status).toBe(200);
done();
});
});
Expand Down Expand Up @@ -282,7 +282,7 @@ module.exports = function (request, config, isServer) {
expect(!err).toBe(true);
expect(result.match[1]).toBe('666');
expect(result.data).toBe('Fixture !');
expect(result.code).toBe(201);
expect(result.status).toBe(201);
done();
});
});
Expand Down Expand Up @@ -502,7 +502,7 @@ module.exports = function (request, config, isServer) {
expect(!err).toBe(true);
expect(result.match[1]).toBe('666');
expect(result.data).toBe('Fixture !');
expect(result.code).toBe(201);
expect(result.status).toBe(201);
done();
});
});
Expand Down

0 comments on commit 68df77e

Please sign in to comment.