Run Prettier on all files

This commit is contained in:
Steve Gravrock
2020-09-29 18:05:38 -07:00
parent 7d5ca27b9d
commit d27bb8fa96
108 changed files with 4399 additions and 2926 deletions

View File

@@ -21,7 +21,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
* @return {string} The pretty-printed value
*/
this.pp = options.pp || function() {};
};
}
/**
* Determines whether `haystack` contains `needle`, using the same comparison
@@ -39,9 +39,10 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
return haystack.has(needle);
}
if ((Object.prototype.toString.apply(haystack) === '[object Array]') ||
(!!haystack && !haystack.indexOf))
{
if (
Object.prototype.toString.apply(haystack) === '[object Array]' ||
(!!haystack && !haystack.indexOf)
) {
for (var i = 0; i < haystack.length; i++) {
if (this.equals(haystack[i], needle, customTesters)) {
return true;
@@ -60,9 +61,12 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
isNot = args[1],
actual = args[2],
expected = args.slice(3),
englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) {
return ' ' + s.toLowerCase();
});
var message = 'Expected ' +
var message =
'Expected ' +
self.pp(actual) +
(isNot ? ' not ' : ' ') +
englishyPredicate;
@@ -79,20 +83,41 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
return message + '.';
};
MatchersUtil.prototype.asymmetricDiff_ = function(a, b, aStack, bStack, customTesters, diffBuilder) {
MatchersUtil.prototype.asymmetricDiff_ = function(
a,
b,
aStack,
bStack,
customTesters,
diffBuilder
) {
if (j$.isFunction_(b.valuesForDiff_)) {
var values = b.valuesForDiff_(a, this.pp);
this.eq_(values.other, values.self, aStack, bStack, customTesters, diffBuilder);
this.eq_(
values.other,
values.self,
aStack,
bStack,
customTesters,
diffBuilder
);
} else {
diffBuilder.recordMismatch();
}
};
MatchersUtil.prototype.asymmetricMatch_ = function(a, b, aStack, bStack, customTesters, diffBuilder) {
MatchersUtil.prototype.asymmetricMatch_ = function(
a,
b,
aStack,
bStack,
customTesters,
diffBuilder
) {
var asymmetricA = j$.isAsymmetricEqualityTester_(a),
asymmetricB = j$.isAsymmetricEqualityTester_(b),
shim,
result;
asymmetricB = j$.isAsymmetricEqualityTester_(b),
shim,
result;
if (asymmetricA === asymmetricB) {
return undefined;
@@ -127,7 +152,12 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
* @param [customTesters] An array of custom equality testers
* @returns {boolean} True if the values are equal
*/
MatchersUtil.prototype.equals = function(a, b, customTestersOrDiffBuilder, diffBuilderOrNothing) {
MatchersUtil.prototype.equals = function(
a,
b,
customTestersOrDiffBuilder,
diffBuilderOrNothing
) {
var customTesters, diffBuilder;
if (isDiffBuilder(customTestersOrDiffBuilder)) {
@@ -146,10 +176,26 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
// Equality function lovingly adapted from isEqual in
// [Underscore](http://underscorejs.org)
MatchersUtil.prototype.eq_ = function(a, b, aStack, bStack, customTesters, diffBuilder) {
var result = true, self = this, i;
MatchersUtil.prototype.eq_ = function(
a,
b,
aStack,
bStack,
customTesters,
diffBuilder
) {
var result = true,
self = this,
i;
var asymmetricResult = this.asymmetricMatch_(a, b, aStack, bStack, customTesters, diffBuilder);
var asymmetricResult = this.asymmetricMatch_(
a,
b,
aStack,
bStack,
customTesters,
diffBuilder
);
if (!j$.util.isUndefined(asymmetricResult)) {
return asymmetricResult;
}
@@ -207,7 +253,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
case '[object Number]':
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
// other numeric values.
result = a != +a ? b != +b : (a === 0 && b === 0 ? 1 / a == 1 / b : a == +b);
result =
a != +a ? b != +b : a === 0 && b === 0 ? 1 / a == 1 / b : a == +b;
if (!result) {
diffBuilder.recordMismatch();
}
@@ -224,10 +271,12 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
return result;
// RegExps are compared by their source patterns and flags.
case '[object RegExp]':
return a.source == b.source &&
return (
a.source == b.source &&
a.global == b.global &&
a.multiline == b.multiline &&
a.ignoreCase == b.ignoreCase;
a.ignoreCase == b.ignoreCase
);
}
if (typeof a != 'object' || typeof b != 'object') {
diffBuilder.recordMismatch();
@@ -261,7 +310,9 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
while (length--) {
// Linear search. Performance is inversely proportional to the number of
// unique nested structures.
if (aStack[length] == a) { return bStack[length] == b; }
if (aStack[length] == a) {
return bStack[length] == b;
}
}
// Add the first object to the stack of traversed objects.
aStack.push(a);
@@ -283,10 +334,20 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
for (i = 0; i < aLength || i < bLength; i++) {
diffBuilder.withPath(i, function() {
if (i >= bLength) {
diffBuilder.recordMismatch(actualArrayIsLongerFormatter.bind(null, self.pp));
diffBuilder.recordMismatch(
actualArrayIsLongerFormatter.bind(null, self.pp)
);
result = false;
} else {
result = self.eq_(i < aLength ? a[i] : void 0, i < bLength ? b[i] : void 0, aStack, bStack, customTesters, diffBuilder) && result;
result =
self.eq_(
i < aLength ? a[i] : void 0,
i < bLength ? b[i] : void 0,
aStack,
bStack,
customTesters,
diffBuilder
) && result;
}
});
}
@@ -301,11 +362,11 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
var keysA = [];
var keysB = [];
a.forEach( function( valueA, keyA ) {
keysA.push( keyA );
a.forEach(function(valueA, keyA) {
keysA.push(keyA);
});
b.forEach( function( valueB, keyB ) {
keysB.push( keyB );
b.forEach(function(valueB, keyB) {
keysB.push(keyB);
});
// For both sets of keys, check they map to equal values in both maps.
@@ -326,13 +387,30 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
// Only use the cmpKey when one of the keys is asymmetric and the corresponding key matches,
// otherwise explicitly look up the mapKey in the other Map since we want keys with unique
// obj identity (that are otherwise equal) to not match.
if (j$.isAsymmetricEqualityTester_(mapKey) || j$.isAsymmetricEqualityTester_(cmpKey) &&
this.eq_(mapKey, cmpKey, aStack, bStack, customTesters, j$.NullDiffBuilder())) {
if (
j$.isAsymmetricEqualityTester_(mapKey) ||
(j$.isAsymmetricEqualityTester_(cmpKey) &&
this.eq_(
mapKey,
cmpKey,
aStack,
bStack,
customTesters,
j$.NullDiffBuilder()
))
) {
mapValueB = b.get(cmpKey);
} else {
mapValueB = b.get(mapKey);
}
result = this.eq_(mapValueA, mapValueB, aStack, bStack, customTesters, j$.NullDiffBuilder());
result = this.eq_(
mapValueA,
mapValueB,
aStack,
bStack,
customTesters,
j$.NullDiffBuilder()
);
}
}
@@ -347,12 +425,12 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
}
var valuesA = [];
a.forEach( function( valueA ) {
valuesA.push( valueA );
a.forEach(function(valueA) {
valuesA.push(valueA);
});
var valuesB = [];
b.forEach( function( valueB ) {
valuesB.push( valueB );
b.forEach(function(valueB) {
valuesB.push(valueB);
});
// For both sets, check they are all contained in the other set
@@ -376,7 +454,14 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
otherValue = otherValues[l];
prevStackSize = baseStack.length;
// compare by value equality
found = this.eq_(baseValue, otherValue, baseStack, otherStack, customTesters, j$.NullDiffBuilder());
found = this.eq_(
baseValue,
otherValue,
baseStack,
otherStack,
customTesters,
j$.NullDiffBuilder()
);
if (!found && prevStackSize !== baseStack.length) {
baseStack.splice(prevStackSize);
otherStack.splice(prevStackSize);
@@ -391,27 +476,35 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
return false;
}
} else {
// Objects with different constructors are not equivalent, but `Object`s
// or `Array`s from different frames are.
var aCtor = a.constructor, bCtor = b.constructor;
if (aCtor !== bCtor &&
isFunction(aCtor) && isFunction(bCtor) &&
a instanceof aCtor && b instanceof bCtor &&
!(aCtor instanceof aCtor && bCtor instanceof bCtor)) {
diffBuilder.recordMismatch(constructorsAreDifferentFormatter.bind(null, this.pp));
var aCtor = a.constructor,
bCtor = b.constructor;
if (
aCtor !== bCtor &&
isFunction(aCtor) &&
isFunction(bCtor) &&
a instanceof aCtor &&
b instanceof bCtor &&
!(aCtor instanceof aCtor && bCtor instanceof bCtor)
) {
diffBuilder.recordMismatch(
constructorsAreDifferentFormatter.bind(null, this.pp)
);
return false;
}
}
// Deep compare objects.
var aKeys = keys(a, className == '[object Array]'), key;
var aKeys = keys(a, className == '[object Array]'),
key;
size = aKeys.length;
// Ensure that both objects contain the same number of properties before comparing deep equality.
if (keys(b, className == '[object Array]').length !== size) {
diffBuilder.recordMismatch(objectKeysAreDifferentFormatter.bind(null, this.pp));
diffBuilder.recordMismatch(
objectKeysAreDifferentFormatter.bind(null, this.pp)
);
return false;
}
@@ -419,13 +512,17 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
key = aKeys[i];
// Deep compare each member
if (!j$.util.has(b, key)) {
diffBuilder.recordMismatch(objectKeysAreDifferentFormatter.bind(null, this.pp));
diffBuilder.recordMismatch(
objectKeysAreDifferentFormatter.bind(null, this.pp)
);
result = false;
continue;
}
diffBuilder.withPath(key, function() {
if(!self.eq_(a[key], b[key], aStack, bStack, customTesters, diffBuilder)) {
if (
!self.eq_(a[key], b[key], aStack, bStack, customTesters, diffBuilder)
) {
result = false;
}
});
@@ -443,23 +540,24 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
};
function keys(obj, isArray) {
var allKeys = Object.keys ? Object.keys(obj) :
(function(o) {
var allKeys = Object.keys
? Object.keys(obj)
: (function(o) {
var keys = [];
for (var key in o) {
if (j$.util.has(o, key)) {
keys.push(key);
}
if (j$.util.has(o, key)) {
keys.push(key);
}
}
return keys;
})(obj);
})(obj);
if (!isArray) {
return allKeys;
}
if (allKeys.length === 0) {
return allKeys;
return allKeys;
}
var extraKeys = [];
@@ -478,21 +576,25 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
function objectKeysAreDifferentFormatter(pp, actual, expected, path) {
var missingProperties = j$.util.objectDifference(expected, actual),
extraProperties = j$.util.objectDifference(actual, expected),
missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties),
extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties),
messages = [];
extraProperties = j$.util.objectDifference(actual, expected),
missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties),
extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties),
messages = [];
if (!path.depth()) {
path = 'object';
}
if (missingPropertiesMessage.length) {
messages.push('Expected ' + path + ' to have properties' + missingPropertiesMessage);
messages.push(
'Expected ' + path + ' to have properties' + missingPropertiesMessage
);
}
if (extraPropertiesMessage.length) {
messages.push('Expected ' + path + ' not to have properties' + extraPropertiesMessage);
messages.push(
'Expected ' + path + ' not to have properties' + extraPropertiesMessage
);
}
return messages.join('\n');
@@ -503,17 +605,25 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
path = 'object';
}
return 'Expected ' +
path + ' to be a kind of ' +
return (
'Expected ' +
path +
' to be a kind of ' +
j$.fnNameFor(expected.constructor) +
', but was ' + pp(actual) + '.';
', but was ' +
pp(actual) +
'.'
);
}
function actualArrayIsLongerFormatter(pp, actual, expected, path) {
return 'Unexpected ' +
path + (path.depth() ? ' = ' : '') +
return (
'Unexpected ' +
path +
(path.depth() ? ' = ' : '') +
pp(actual) +
' in array.';
' in array.'
);
}
function formatKeyValuePairs(pp, obj) {