Skip to content

Commit

Permalink
Add test for issue #1274
Browse files Browse the repository at this point in the history
  • Loading branch information
takasmiley committed Jun 28, 2017
1 parent d8f005b commit 62ee2e0
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/issues/issues-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,49 @@ describe("issues", function () {
});
});
}

describe("#1274 - spy.withArgs(args...).callCount is incorrect", function () {
it("case1: should count accurately", function () {
var obj = {
f: function () {}
};

// case1: withArgs(1) => withArgs(1, 1)
var spy = sinon.spy(obj, "f");
assert.equals(spy.callCount, 0);
assert.equals(spy.withArgs(1).callCount, 0);
assert.equals(spy.withArgs(1, 1).callCount, 0);

obj.f();
obj.f(1);
obj.f(1, 1);
obj.f(1, 2);

assert.equals(spy.callCount, 4);
assert.equals(spy.withArgs(1).callCount, 3);
assert.equals(spy.withArgs(1, 1).callCount, 1);
assert.equals(spy.withArgs(1, 2).callCount, 1);
});
it("case2: should count accurately", function () {
var obj = {
f: function () {}
};

// case2: withArgs(1, 1) => withArgs(1)
var spy = sinon.spy(obj, "f");
assert.equals(spy.callCount, 0);
assert.equals(spy.withArgs(1, 1).callCount, 0);
assert.equals(spy.withArgs(1).callCount, 0);

obj.f();
obj.f(1);
obj.f(1, 1);
obj.f(1, 2);

assert.equals(spy.callCount, 4);
assert.equals(spy.withArgs(1).callCount, 3);
assert.equals(spy.withArgs(1, 1).callCount, 1);
assert.equals(spy.withArgs(1, 2).callCount, 1);
});
});
});

0 comments on commit 62ee2e0

Please sign in to comment.