Skip to content

Commit

Permalink
Fix #1476: spy.withArgs(args...).firstCall is broken
Browse files Browse the repository at this point in the history
  • Loading branch information
takasmiley committed Jun 30, 2017
1 parent 8ad2ed7 commit c280916
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/sinon/spy.js
Expand Up @@ -179,6 +179,9 @@ var spyApi = {

// Make call properties available from within the spied function:
createCallProperties.call(this);
matchings.forEach(function (matching) {
createCallProperties.call(matching);
});

try {
this.invoking = true;
Expand Down
9 changes: 9 additions & 0 deletions test/stub-test.js
Expand Up @@ -115,6 +115,15 @@ describe("stub", function () {
assert.equals(stub(2), 0);
});

it("should work with combination of withArgs arguments", function () {
var stub = createStub();

stub.withArgs(1).returns(42);
stub(1);

assert.isObject(stub.withArgs(1).firstCall);
});

describe(".returns", function () {
it("returns specified value", function () {
var stub = createStub.create();
Expand Down

0 comments on commit c280916

Please sign in to comment.