-
-
Notifications
You must be signed in to change notification settings - Fork 771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #1476: stub#firstCall seems broken on sinon v2.3.6 #1478
Conversation
That was quick :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small things to clean up. Thanks for the quick fix! :)
test/stub-test.js
Outdated
stub.withArgs(1).returns(42); | ||
stub(1); | ||
|
||
assert.isObject(stub.withArgs(1).firstCall); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would assert it's not null
here. While being an object has the same effect, is not null is a bit more explicit.
test/spy-test.js
Outdated
@@ -326,7 +326,62 @@ describe("spy", function () { | |||
}); | |||
}); | |||
|
|||
it("counts with combination of withArgs arguments and order of calling withArgs", function () { | |||
it("should work with combination of withArgs arguments and order of calling withArgs", function () { | |||
var assertSpy = function (spy) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just make it a function expression instead. function assertSpy()...
test/spy-test.js
Outdated
spy.getCall(2)[propName]); | ||
assert.equals(spy.withArgs(1).getCall(2)[propName], | ||
spy.getCall(3)[propName]); | ||
assert.equals(spy.withArgs(1).getCall(3), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use assert.isNull
throughout.
test/spy-test.js
Outdated
assert.equals(spy.withArgs(1, 2).callCount, 1); | ||
|
||
// assert call | ||
assert.equals(spy.getCall(0).args[0], undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use refute.defined
assertion throughout.
Hmm it seems with this patch (in 2.3.7) withArgs().lastCall is broken. |
99 bugs of Sinon on the wall, 99 bugs of Sinon. 😭 Seriously, we need some more tests to catch these things. These things are fragile. @jvanoostveen, could you create an issue with a small reproducible testcase? P.S. We see all activity on the tracker, so you only need to comment in one issue or cross-reference from the issue you are reporting (Github makes links to the issues when using hash-prefixed issues, such as "#1476"). |
It isn't all bad, I've been very happy with Sinon overall. :) After updating from 2.3.5 to 2.3.7 we suddenly have some failing tests. (2.3.6 was also failing, can't remember if they where the same tests.) |
Fix issue #1476
The cause of this bug is that
createCallProperties(matching)
is never called in spy.js.