diff --git a/test/match-test.js b/test/match-test.js index 2be5be761..08f567b44 100644 --- a/test/match-test.js +++ b/test/match-test.js @@ -123,6 +123,12 @@ describe("sinonMatch", function () { assert.isFalse(match.test({ arr: ["a", "b"] })); }); + it("returns false if array is not equal (even if the contents would match (deep equal))", function () { + var match = sinonMatch([{ str: "sinon" }]); + + assert.isFalse(match.test([{ str: "sinon", ignored: "value" }])); + }); + it("returns true if number objects are equal", function () { /*eslint-disable no-new-wrappers*/ var match = sinonMatch({ one: new Number(1) }); @@ -1059,4 +1065,18 @@ describe("sinonMatch", function () { assert(falsyAndUndefined.test(undefined)); }); }); + + describe("nested", function () { + it("returns true for an object with nested matcher", function () { + var match = sinonMatch({outer: sinonMatch({ inner: "sinon" })}); + + assert.isTrue(match.test({outer: { inner: "sinon", foo: "bar" }})); + }); + + it("returns true for an array of nested matchers", function () { + var match = sinonMatch([sinonMatch({ str: "sinon" })]); + + assert.isTrue(match.test([{ str: "sinon", foo: "bar" }])); + }); + }); });