diff --git a/lib/sinon/util/core/deep-equal.js b/lib/sinon/util/core/deep-equal.js index 5c9ac9762..d1d2b6270 100644 --- a/lib/sinon/util/core/deep-equal.js +++ b/lib/sinon/util/core/deep-equal.js @@ -38,11 +38,12 @@ var deepEqual = module.exports = function deepEqual(a, b, matcher) { } if (matcher) { - var allKeysMatch = every(Object.keys(a), function (key) { + var keys = Object.keys(a); + var allKeysMatch = every(keys, function (key) { return matcher(a[key], b[key]); }); - return allKeysMatch; + return keys.length > 0 && allKeysMatch; } return false; diff --git a/test/issues/issues-test.js b/test/issues/issues-test.js index cace92937..e801aa918 100644 --- a/test/issues/issues-test.js +++ b/test/issues/issues-test.js @@ -520,4 +520,17 @@ describe("issues", function () { stub.restore(); }); }); + + describe("#1900 - calledWith returns false positive", function () { + it("should return false when call args don't match", function () { + var spy = sinon.spy(); + var dateOne = new Date("2018-07-01"); + var dateTwo = new Date("2018-07-31"); + + spy(dateOne); + + var calledWith = spy.calledWith(dateTwo); + assert.same(calledWith, false); + }); + }); });