sinon.deepEqual(new Date(0), new Date()) returns true.
sinon.deepEqual returns true for every two dates, even if they don't match.
I found out this problem, when my mock expectation didn't throw when it was called with the wrong date.
This is how they are handled in underscore(and almost same in lodash) https://github.com/documentcloud/underscore/blob/master/underscore.js#L832-837. Looking at the code, seems like we also lack for the check of other native classes.
The next version of Sinon will replace it's deepEqual with that of Samsam, which does not have this problem.
That would be awesome.
How are you going to put the matchers support in deepEqual then?
I don't quite remember, but samsam either supports or will soon support custom check hooks. I don't intend to break anything :)
I saw a match function in samsam that is quite similar to sinon.match. You could also move the matchers into samsam entirely. That would also provide that custom check hook.
Yeah, that match is the gut of Buster's assert.match, which works a little differently. But having it support the Sinon matchers as well would probably be a good idea. I'll look into it when integrating the two.
Hi, everybody. I don't quite understand, why this issue is closed, deepEqual still behaves incorrectly as of 1.7.1. Here is the test case:
var foo = function(date){};
var spy = sinon.spy(foo);
spy(new Date(2013, 4, 28, 10, 27, 51));
sinon.assert.calledWithExactly(spy, new Date(2012, 4, 28, 10, 27, 51)); // <-- will not fail
Yeah. Too much enthusiasm on our side to use samsam which will most certainly not happen in 1.x. Reopening. Care to provide a patch?
Ok, I'll try to submit a patch later today.
Fixed by @gserebryanskyi in #289
Is there any way to correctly check deep equality of dates in a call to spy.calledWithExactly?
It should just work™️. If you have an issue with dates and calledWithExactly, please open a new issue with a description stating what you expect to happen and what actually happens. If you have a usage question, it's probably best to post your question on StackOverflow using the Sinon tag. Thanks.