Skip to content

Commit

Permalink
Merge pull request #1320 from ashirley/master
Browse files Browse the repository at this point in the history
Add test cases for nested matchers and arrays
  • Loading branch information
fatso83 committed Mar 27, 2017
2 parents 17c2639 + d61cabc commit c633202
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/match-test.js
Expand Up @@ -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) });
Expand Down Expand Up @@ -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" }]));
});
});
});

0 comments on commit c633202

Please sign in to comment.