Pass custom testers to asymmetric testers

This allows custom equality testers to affect asymmetric matches.
This avoid suprises when combining addCustomEqualityTester with
objectContaining or arrayContaining.

Closes #1138
This commit is contained in:
Joey Parrish
2016-06-23 14:33:39 -07:00
parent f6da084642
commit de7b7c029e
8 changed files with 75 additions and 16 deletions

View File

@@ -36,4 +36,17 @@ describe("ArrayContaining", function() {
expect(containing.jasmineToString()).toMatch("<jasmine.arrayContaining");
});
it("uses custom equality testers", function() {
var tester = function(a, b) {
// All "foo*" strings match each other.
if (typeof a == "string" && typeof b == "string" &&
a.substr(0, 3) == "foo" && b.substr(0, 3) == "foo") {
return true;
}
};
var containing = new jasmineUnderTest.ArrayContaining(["fooVal"]);
expect(containing.asymmetricMatch(["fooBar"], [tester])).toBe(true);
});
});