Check for ObjectContaining on either side of equality.

- Also clean up `undefined` check.

Fixes #682
This commit is contained in:
slackersoft
2014-12-16 17:05:32 -08:00
parent 6bd98cb2ab
commit ea88023553
5 changed files with 28 additions and 14 deletions

View File

@@ -43,4 +43,16 @@ describe("ObjectContaining", function() {
expect(containing.asymmetricMatch({one: {two: {}}})).toBe(true);
});
it("matches when key is present with undefined value", function() {
var containing = new j$.ObjectContaining({ one: undefined });
expect(containing.asymmetricMatch({ one: undefined })).toBe(true);
});
it("does not match when key with undefined value is not present", function() {
var containing = new j$.ObjectContaining({ one: undefined });
expect(containing.asymmetricMatch({})).toBe(false);
});
});

View File

@@ -191,9 +191,11 @@ describe("matchersUtil", function() {
var obj = {
foo: 3,
bar: 7
};
},
containing = new j$.ObjectContaining({foo: 3});
expect(j$.matchersUtil.equals(obj, new j$.ObjectContaining({foo: 3}))).toBe(true);
expect(j$.matchersUtil.equals(obj, containing)).toBe(true);
expect(j$.matchersUtil.equals(containing, obj)).toBe(true);
});
it("passes when a custom equality matcher returns true", function() {