Skip to content

Commit

Permalink
Add method to the fixtures' context object (#65)
Browse files Browse the repository at this point in the history
support checking for example if put or delete for the same url (crud rest apis)
  • Loading branch information
elisherer authored and Florent Dubost committed Jul 25, 2017
1 parent 5742e47 commit c7a0205
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/superagent-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,12 @@ module.exports = function (superagent, config, logger) {

const context = {};
try {
const method = this.method.toLocaleLowerCase();
context.method = method;
const fixtures = parser.fixtures(match, this._data, this.header, context);
if (context.cancel === true) {
return oldEnd.call(this, fn); // mocking was cancelled from within fixtures
}
const method = this.method.toLocaleLowerCase();
const parserMethod = parser[method] || parser.callback;
response = parserMethod(match, fixtures);
} catch (err) {
Expand Down

0 comments on commit c7a0205

Please sign in to comment.