Merge branch 'custom-object-formatters' into cof-merge-candidate

This commit is contained in:
Steve Gravrock
2020-02-11 11:44:38 -08:00
84 changed files with 3047 additions and 1017 deletions

View File

@@ -3,7 +3,7 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
this.sample = sample;
}
ArrayContaining.prototype.asymmetricMatch = function(other, customTesters) {
ArrayContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.isArray_(this.sample)) {
throw new Error('You must provide an array to arrayContaining, not ' + j$.pp(this.sample) + '.');
}
@@ -17,7 +17,7 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
for (var i = 0; i < this.sample.length; i++) {
var item = this.sample[i];
if (!j$.matchersUtil.contains(other, item, customTesters)) {
if (!matchersUtil.contains(other, item)) {
return false;
}
}
@@ -25,8 +25,8 @@ getJasmineRequireObj().ArrayContaining = function(j$) {
return true;
};
ArrayContaining.prototype.jasmineToString = function () {
return '<jasmine.arrayContaining(' + j$.pp(this.sample) +')>';
ArrayContaining.prototype.jasmineToString = function (pp) {
return '<jasmine.arrayContaining(' + pp(this.sample) +')>';
};
return ArrayContaining;

View File

@@ -4,7 +4,7 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) {
this.sample = sample;
}
ArrayWithExactContents.prototype.asymmetricMatch = function(other, customTesters) {
ArrayWithExactContents.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.isArray_(this.sample)) {
throw new Error('You must provide an array to arrayWithExactContents, not ' + j$.pp(this.sample) + '.');
}
@@ -15,7 +15,7 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) {
for (var i = 0; i < this.sample.length; i++) {
var item = this.sample[i];
if (!j$.matchersUtil.contains(other, item, customTesters)) {
if (!matchersUtil.contains(other, item)) {
return false;
}
}
@@ -23,8 +23,8 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) {
return true;
};
ArrayWithExactContents.prototype.jasmineToString = function() {
return '<jasmine.arrayWithExactContents ' + j$.pp(this.sample) + '>';
ArrayWithExactContents.prototype.jasmineToString = function(pp) {
return '<jasmine.arrayWithExactContents(' + pp(this.sample) + ')>';
};
return ArrayWithExactContents;

View File

@@ -7,7 +7,7 @@ getJasmineRequireObj().MapContaining = function(j$) {
this.sample = sample;
}
MapContaining.prototype.asymmetricMatch = function(other, customTesters) {
MapContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.isMap(other)) return false;
var hasAllMatches = true;
@@ -17,8 +17,8 @@ getJasmineRequireObj().MapContaining = function(j$) {
var hasMatch = false;
j$.util.forEachBreakable(other, function(oBreakLoop, oValue, oKey) {
if (
j$.matchersUtil.equals(oKey, key, customTesters)
&& j$.matchersUtil.equals(oValue, value, customTesters)
matchersUtil.equals(oKey, key)
&& matchersUtil.equals(oValue, value)
) {
hasMatch = true;
oBreakLoop();
@@ -33,8 +33,8 @@ getJasmineRequireObj().MapContaining = function(j$) {
return hasAllMatches;
};
MapContaining.prototype.jasmineToString = function() {
return '<jasmine.mapContaining(' + j$.pp(this.sample) + ')>';
MapContaining.prototype.jasmineToString = function(pp) {
return '<jasmine.mapContaining(' + pp(this.sample) + ')>';
};
return MapContaining;

View File

@@ -28,13 +28,13 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
return hasProperty(getPrototype(obj), property);
}
ObjectContaining.prototype.asymmetricMatch = function(other, customTesters) {
ObjectContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (typeof(this.sample) !== 'object') { throw new Error('You must provide an object to objectContaining, not \''+this.sample+'\'.'); }
if (typeof(other) !== 'object') { return false; }
for (var property in this.sample) {
if (!hasProperty(other, property) ||
!j$.matchersUtil.equals(this.sample[property], other[property], customTesters)) {
!matchersUtil.equals(this.sample[property], other[property])) {
return false;
}
}
@@ -42,10 +42,10 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
return true;
};
ObjectContaining.prototype.valuesForDiff_ = function(other) {
ObjectContaining.prototype.valuesForDiff_ = function(other, pp) {
if (!j$.isObject_(other)) {
return {
self: this.jasmineToString(),
self: this.jasmineToString(pp),
other: other
};
}
@@ -63,8 +63,8 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
};
};
ObjectContaining.prototype.jasmineToString = function() {
return '<jasmine.objectContaining(' + j$.pp(this.sample) + ')>';
ObjectContaining.prototype.jasmineToString = function(pp) {
return '<jasmine.objectContaining(' + pp(this.sample) + ')>';
};
return ObjectContaining;

View File

@@ -7,17 +7,17 @@ getJasmineRequireObj().SetContaining = function(j$) {
this.sample = sample;
}
SetContaining.prototype.asymmetricMatch = function(other, customTesters) {
SetContaining.prototype.asymmetricMatch = function(other, matchersUtil) {
if (!j$.isSet(other)) return false;
var hasAllMatches = true;
j$.util.forEachBreakable(this.sample, function(breakLoop, item) {
// for each item in `sample` there should be at least one matching item in `other`
// (not using `j$.matchersUtil.contains` because it compares set members by reference,
// (not using `matchersUtil.contains` because it compares set members by reference,
// not by deep value equality)
var hasMatch = false;
j$.util.forEachBreakable(other, function(oBreakLoop, oItem) {
if (j$.matchersUtil.equals(oItem, item, customTesters)) {
if (matchersUtil.equals(oItem, item)) {
hasMatch = true;
oBreakLoop();
}
@@ -31,8 +31,8 @@ getJasmineRequireObj().SetContaining = function(j$) {
return hasAllMatches;
};
SetContaining.prototype.jasmineToString = function() {
return '<jasmine.setContaining(' + j$.pp(this.sample) + ')>';
SetContaining.prototype.jasmineToString = function(pp) {
return '<jasmine.setContaining(' + pp(this.sample) + ')>';
};
return SetContaining;