Merge branch 'custom-testers-in-asymmetric-matchers' of https://github.com/joeyparrish/jasmine into joeyparrish-custom-testers-in-asymmetric-matchers
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
||||
return obj && j$.isA_('Function', obj.asymmetricMatch);
|
||||
}
|
||||
|
||||
function asymmetricMatch(a, b) {
|
||||
function asymmetricMatch(a, b, customTesters) {
|
||||
var asymmetricA = isAsymmetric(a),
|
||||
asymmetricB = isAsymmetric(b);
|
||||
|
||||
@@ -64,11 +64,11 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
||||
}
|
||||
|
||||
if (asymmetricA) {
|
||||
return a.asymmetricMatch(b);
|
||||
return a.asymmetricMatch(b, customTesters);
|
||||
}
|
||||
|
||||
if (asymmetricB) {
|
||||
return b.asymmetricMatch(a);
|
||||
return b.asymmetricMatch(a, customTesters);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
||||
function eq(a, b, aStack, bStack, customTesters) {
|
||||
var result = true;
|
||||
|
||||
var asymmetricResult = asymmetricMatch(a, b);
|
||||
var asymmetricResult = asymmetricMatch(a, b, customTesters);
|
||||
if (!j$.util.isUndefined(asymmetricResult)) {
|
||||
return asymmetricResult;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user