Skip to content

Commit

Permalink
Add test for sinonjs#1572
Browse files Browse the repository at this point in the history
  • Loading branch information
mroderick committed Jan 13, 2018
1 parent 0ae60b6 commit 1775ab2
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/issues/issues-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,4 +390,33 @@ describe("issues", function () {
mock.verify();
});
});

describe("#1572 - stub.withArgs() with matchers breaks subsequent stubbing", function () {
it("example 1", function () {
var stub = sinon.stub();

stub.withArgs(sinon.match.any).returns("old");
stub.withArgs(1).returns("new");

var result1 = stub(1);
var result2 = stub(2);

assert.equals(result1, "new");
assert.equals(result2, "old");
});

it("example 2", function () {
var stub = sinon.stub();

stub.withArgs(sinon.match.any).returns("old");
stub.reset();
stub.withArgs(1).returns("new");

var result1 = stub(1);
var result2 = stub(2);

assert.equals(result1, "new");
assert.equals(result2, undefined);
});
});
});

0 comments on commit 1775ab2

Please sign in to comment.