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

@@ -28,12 +28,12 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
return hasProperty(getPrototype(obj), property);
}
ObjectContaining.prototype.asymmetricMatch = function(other) {
ObjectContaining.prototype.asymmetricMatch = function(other, customTesters) {
if (typeof(this.sample) !== 'object') { throw new Error('You must provide an object to objectContaining, not \''+this.sample+'\'.'); }
for (var property in this.sample) {
if (!hasProperty(other, property) ||
!j$.matchersUtil.equals(this.sample[property], other[property])) {
!j$.matchersUtil.equals(this.sample[property], other[property], customTesters)) {
return false;
}
}