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

@@ -3,13 +3,13 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
this.sample = sample;
}
ArrayContaining.prototype.asymmetricMatch = function(other) {
ArrayContaining.prototype.asymmetricMatch = function(other, customTesters) {
var className = Object.prototype.toString.call(this.sample);
if (className !== '[object Array]') { throw new Error('You must provide an array to arrayContaining, not \'' + this.sample + '\'.'); }
for (var i = 0; i < this.sample.length; i++) {
var item = this.sample[i];
if (!j$.matchersUtil.contains(other, item)) {
if (!j$.matchersUtil.contains(other, item, customTesters)) {
return false;
}
}