Replaced uses of var with const/let
This commit is contained in:
@@ -14,7 +14,7 @@ getJasmineRequireObj().toBePending = function(j$) {
|
||||
if (!j$.isPromiseLike(actual)) {
|
||||
throw new Error('Expected toBePending to be called on a promise.');
|
||||
}
|
||||
var want = {};
|
||||
const want = {};
|
||||
return Promise.race([actual, Promise.resolve(want)]).then(
|
||||
function(got) {
|
||||
return { pass: want === got };
|
||||
|
||||
@@ -23,7 +23,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
|
||||
);
|
||||
}
|
||||
|
||||
var expected = getExpectedFromArgs(arg1, arg2, matchersUtil);
|
||||
const expected = getExpectedFromArgs(arg1, arg2, matchersUtil);
|
||||
|
||||
return actualPromise.then(
|
||||
function() {
|
||||
@@ -52,7 +52,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
|
||||
);
|
||||
}
|
||||
|
||||
var actualMessage = actual.message;
|
||||
const actualMessage = actual.message;
|
||||
|
||||
if (
|
||||
actualMessage === expected.message ||
|
||||
@@ -94,7 +94,7 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
|
||||
}
|
||||
|
||||
function getExpectedFromArgs(arg1, arg2, matchersUtil) {
|
||||
var error, message;
|
||||
let error, message;
|
||||
|
||||
if (isErrorConstructor(arg1)) {
|
||||
error = arg1;
|
||||
|
||||
@@ -63,7 +63,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
|
||||
if (j$.isNumber_(haystack.length)) {
|
||||
// Objects that are shaped like arrays but aren't iterable
|
||||
for (var i = 0; i < haystack.length; i++) {
|
||||
for (let i = 0; i < haystack.length; i++) {
|
||||
if (this.equals(haystack[i], needle)) {
|
||||
return true;
|
||||
}
|
||||
@@ -74,8 +74,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
};
|
||||
|
||||
MatchersUtil.prototype.buildFailureMessage = function() {
|
||||
var self = this;
|
||||
var args = Array.prototype.slice.call(arguments, 0),
|
||||
const self = this;
|
||||
const args = Array.prototype.slice.call(arguments, 0),
|
||||
matcherName = args[0],
|
||||
isNot = args[1],
|
||||
actual = args[2],
|
||||
@@ -84,14 +84,14 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
return ' ' + s.toLowerCase();
|
||||
});
|
||||
|
||||
var message =
|
||||
let message =
|
||||
'Expected ' +
|
||||
self.pp(actual) +
|
||||
(isNot ? ' not ' : ' ') +
|
||||
englishyPredicate;
|
||||
|
||||
if (expected.length > 0) {
|
||||
for (var i = 0; i < expected.length; i++) {
|
||||
for (let i = 0; i < expected.length; i++) {
|
||||
if (i > 0) {
|
||||
message += ',';
|
||||
}
|
||||
@@ -110,7 +110,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
diffBuilder
|
||||
) {
|
||||
if (j$.isFunction_(b.valuesForDiff_)) {
|
||||
var values = b.valuesForDiff_(a, this.pp);
|
||||
const values = b.valuesForDiff_(a, this.pp);
|
||||
this.eq_(values.other, values.self, aStack, bStack, diffBuilder);
|
||||
} else {
|
||||
diffBuilder.recordMismatch();
|
||||
@@ -124,14 +124,15 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
bStack,
|
||||
diffBuilder
|
||||
) {
|
||||
var asymmetricA = j$.isAsymmetricEqualityTester_(a),
|
||||
asymmetricB = j$.isAsymmetricEqualityTester_(b),
|
||||
result;
|
||||
const asymmetricA = j$.isAsymmetricEqualityTester_(a);
|
||||
const asymmetricB = j$.isAsymmetricEqualityTester_(b);
|
||||
|
||||
if (asymmetricA === asymmetricB) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let result;
|
||||
|
||||
if (asymmetricA) {
|
||||
result = a.asymmetricMatch(b, this);
|
||||
if (!result) {
|
||||
@@ -168,11 +169,10 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
// Equality function lovingly adapted from isEqual in
|
||||
// [Underscore](http://underscorejs.org)
|
||||
MatchersUtil.prototype.eq_ = function(a, b, aStack, bStack, diffBuilder) {
|
||||
var result = true,
|
||||
self = this,
|
||||
i;
|
||||
let result = true;
|
||||
const self = this;
|
||||
|
||||
var asymmetricResult = this.asymmetricMatch_(
|
||||
const asymmetricResult = this.asymmetricMatch_(
|
||||
a,
|
||||
b,
|
||||
aStack,
|
||||
@@ -183,8 +183,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
return asymmetricResult;
|
||||
}
|
||||
|
||||
for (i = 0; i < this.customTesters_.length; i++) {
|
||||
var customTesterResult = this.customTesters_[i](a, b);
|
||||
for (const tester of this.customTesters_) {
|
||||
const customTesterResult = tester(a, b);
|
||||
if (!j$.util.isUndefined(customTesterResult)) {
|
||||
if (!customTesterResult) {
|
||||
diffBuilder.recordMismatch();
|
||||
@@ -218,7 +218,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
var className = Object.prototype.toString.call(a);
|
||||
const className = Object.prototype.toString.call(a);
|
||||
if (className != Object.prototype.toString.call(b)) {
|
||||
diffBuilder.recordMismatch();
|
||||
return false;
|
||||
@@ -276,8 +276,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aIsDomNode = j$.isDomNode(a);
|
||||
var bIsDomNode = j$.isDomNode(b);
|
||||
const aIsDomNode = j$.isDomNode(a);
|
||||
const bIsDomNode = j$.isDomNode(b);
|
||||
if (aIsDomNode && bIsDomNode) {
|
||||
// At first try to use DOM3 method isEqualNode
|
||||
result = a.isEqualNode(b);
|
||||
@@ -291,15 +291,15 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aIsPromise = j$.isPromise(a);
|
||||
var bIsPromise = j$.isPromise(b);
|
||||
const aIsPromise = j$.isPromise(a);
|
||||
const bIsPromise = j$.isPromise(b);
|
||||
if (aIsPromise && bIsPromise) {
|
||||
return a === b;
|
||||
}
|
||||
|
||||
// Assume equality for cyclic structures. The algorithm for detecting cyclic
|
||||
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
|
||||
var length = aStack.length;
|
||||
let length = aStack.length;
|
||||
while (length--) {
|
||||
// Linear search. Performance is inversely proportional to the number of
|
||||
// unique nested structures.
|
||||
@@ -310,12 +310,12 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
// Add the first object to the stack of traversed objects.
|
||||
aStack.push(a);
|
||||
bStack.push(b);
|
||||
var size = 0;
|
||||
let size = 0;
|
||||
// Recursively compare objects and arrays.
|
||||
// Compare array lengths to determine if a deep comparison is necessary.
|
||||
if (className == '[object Array]') {
|
||||
var aLength = a.length;
|
||||
var bLength = b.length;
|
||||
const aLength = a.length;
|
||||
const bLength = b.length;
|
||||
|
||||
diffBuilder.withPath('length', function() {
|
||||
if (aLength !== bLength) {
|
||||
@@ -324,7 +324,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
}
|
||||
});
|
||||
|
||||
for (i = 0; i < aLength || i < bLength; i++) {
|
||||
for (let i = 0; i < aLength || i < bLength; i++) {
|
||||
diffBuilder.withPath(i, function() {
|
||||
if (i >= bLength) {
|
||||
diffBuilder.recordMismatch(
|
||||
@@ -352,8 +352,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var keysA = [];
|
||||
var keysB = [];
|
||||
const keysA = [];
|
||||
const keysB = [];
|
||||
a.forEach(function(valueA, keyA) {
|
||||
keysA.push(keyA);
|
||||
});
|
||||
@@ -363,18 +363,17 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
|
||||
// For both sets of keys, check they map to equal values in both maps.
|
||||
// Keep track of corresponding keys (in insertion order) in order to handle asymmetric obj keys.
|
||||
var mapKeys = [keysA, keysB];
|
||||
var cmpKeys = [keysB, keysA];
|
||||
var mapIter, mapKey, mapValueA, mapValueB;
|
||||
var cmpIter, cmpKey;
|
||||
for (i = 0; result && i < mapKeys.length; i++) {
|
||||
mapIter = mapKeys[i];
|
||||
cmpIter = cmpKeys[i];
|
||||
const mapKeys = [keysA, keysB];
|
||||
const cmpKeys = [keysB, keysA];
|
||||
for (let i = 0; result && i < mapKeys.length; i++) {
|
||||
const mapIter = mapKeys[i];
|
||||
const cmpIter = cmpKeys[i];
|
||||
|
||||
for (var j = 0; result && j < mapIter.length; j++) {
|
||||
mapKey = mapIter[j];
|
||||
cmpKey = cmpIter[j];
|
||||
mapValueA = a.get(mapKey);
|
||||
for (let j = 0; result && j < mapIter.length; j++) {
|
||||
const mapKey = mapIter[j];
|
||||
const cmpKey = cmpIter[j];
|
||||
const mapValueA = a.get(mapKey);
|
||||
let mapValueB;
|
||||
|
||||
// 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
|
||||
@@ -408,35 +407,30 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var valuesA = [];
|
||||
const valuesA = [];
|
||||
a.forEach(function(valueA) {
|
||||
valuesA.push(valueA);
|
||||
});
|
||||
var valuesB = [];
|
||||
const valuesB = [];
|
||||
b.forEach(function(valueB) {
|
||||
valuesB.push(valueB);
|
||||
});
|
||||
|
||||
// For both sets, check they are all contained in the other set
|
||||
var setPairs = [[valuesA, valuesB], [valuesB, valuesA]];
|
||||
var stackPairs = [[aStack, bStack], [bStack, aStack]];
|
||||
var baseValues, baseValue, baseStack;
|
||||
var otherValues, otherValue, otherStack;
|
||||
var found;
|
||||
var prevStackSize;
|
||||
for (i = 0; result && i < setPairs.length; i++) {
|
||||
baseValues = setPairs[i][0];
|
||||
otherValues = setPairs[i][1];
|
||||
baseStack = stackPairs[i][0];
|
||||
otherStack = stackPairs[i][1];
|
||||
const setPairs = [[valuesA, valuesB], [valuesB, valuesA]];
|
||||
const stackPairs = [[aStack, bStack], [bStack, aStack]];
|
||||
for (let i = 0; result && i < setPairs.length; i++) {
|
||||
const baseValues = setPairs[i][0];
|
||||
const otherValues = setPairs[i][1];
|
||||
const baseStack = stackPairs[i][0];
|
||||
const otherStack = stackPairs[i][1];
|
||||
// For each value in the base set...
|
||||
for (var k = 0; result && k < baseValues.length; k++) {
|
||||
baseValue = baseValues[k];
|
||||
found = false;
|
||||
for (const baseValue of baseValues) {
|
||||
let found = false;
|
||||
// ... test that it is present in the other set
|
||||
for (var l = 0; !found && l < otherValues.length; l++) {
|
||||
otherValue = otherValues[l];
|
||||
prevStackSize = baseStack.length;
|
||||
for (let j = 0; !found && j < otherValues.length; j++) {
|
||||
const otherValue = otherValues[j];
|
||||
const prevStackSize = baseStack.length;
|
||||
// compare by value equality
|
||||
found = this.eq_(
|
||||
baseValue,
|
||||
@@ -465,7 +459,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
} else {
|
||||
// Objects with different constructors are not equivalent, but `Object`s
|
||||
// or `Array`s from different frames are.
|
||||
var aCtor = a.constructor,
|
||||
const aCtor = a.constructor,
|
||||
bCtor = b.constructor;
|
||||
if (
|
||||
aCtor !== bCtor &&
|
||||
@@ -483,8 +477,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
}
|
||||
|
||||
// Deep compare objects.
|
||||
var aKeys = MatchersUtil.keys(a, className == '[object Array]'),
|
||||
key;
|
||||
const aKeys = MatchersUtil.keys(a, className == '[object Array]');
|
||||
size = aKeys.length;
|
||||
|
||||
// Ensure that both objects contain the same number of properties before comparing deep equality.
|
||||
@@ -495,8 +488,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
key = aKeys[i];
|
||||
for (const key of aKeys) {
|
||||
// Deep compare each member
|
||||
if (!j$.util.has(b, key)) {
|
||||
diffBuilder.recordMismatch(
|
||||
@@ -525,18 +517,18 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
};
|
||||
|
||||
MatchersUtil.keys = function(obj, isArray) {
|
||||
var allKeys = (function(o) {
|
||||
var keys = [];
|
||||
for (var key in o) {
|
||||
const allKeys = (function(o) {
|
||||
const keys = [];
|
||||
for (const key in o) {
|
||||
if (j$.util.has(o, key)) {
|
||||
keys.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
var symbols = Object.getOwnPropertySymbols(o);
|
||||
for (var i = 0; i < symbols.length; i++) {
|
||||
if (o.propertyIsEnumerable(symbols[i])) {
|
||||
keys.push(symbols[i]);
|
||||
const symbols = Object.getOwnPropertySymbols(o);
|
||||
for (const sym of symbols) {
|
||||
if (o.propertyIsEnumerable(sym)) {
|
||||
keys.push(sym);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,10 +543,10 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
return allKeys;
|
||||
}
|
||||
|
||||
var extraKeys = [];
|
||||
for (var i = 0; i < allKeys.length; i++) {
|
||||
if (typeof allKeys[i] === 'symbol' || !/^[0-9]+$/.test(allKeys[i])) {
|
||||
extraKeys.push(allKeys[i]);
|
||||
const extraKeys = [];
|
||||
for (const k of allKeys) {
|
||||
if (typeof k === 'symbol' || !/^[0-9]+$/.test(k)) {
|
||||
extraKeys.push(k);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,7 +566,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
}
|
||||
|
||||
function objectKeysAreDifferentFormatter(pp, actual, expected, path) {
|
||||
var missingProperties = extraKeysAndValues(expected, actual),
|
||||
const missingProperties = extraKeysAndValues(expected, actual),
|
||||
extraProperties = extraKeysAndValues(actual, expected),
|
||||
missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties),
|
||||
extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) {
|
||||
var availableMatchers = [
|
||||
const availableMatchers = [
|
||||
'toBePending',
|
||||
'toBeResolved',
|
||||
'toBeRejected',
|
||||
@@ -9,8 +9,7 @@ getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) {
|
||||
],
|
||||
matchers = {};
|
||||
|
||||
for (var i = 0; i < availableMatchers.length; i++) {
|
||||
var name = availableMatchers[i];
|
||||
for (const name of availableMatchers) {
|
||||
matchers[name] = jRequire[name](j$);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
|
||||
var availableMatchers = [
|
||||
const availableMatchers = [
|
||||
'nothing',
|
||||
'toBe',
|
||||
'toBeCloseTo',
|
||||
@@ -35,8 +35,7 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
|
||||
],
|
||||
matchers = {};
|
||||
|
||||
for (var i = 0; i < availableMatchers.length; i++) {
|
||||
var name = availableMatchers[i];
|
||||
for (const name of availableMatchers) {
|
||||
matchers[name] = jRequire[name](j$);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@ getJasmineRequireObj().toBe = function(j$) {
|
||||
* expect(thing).toBe(realThing);
|
||||
*/
|
||||
function toBe(matchersUtil) {
|
||||
var tip =
|
||||
const tip =
|
||||
' Tip: To check for deep equality, use .toEqual() instead of .toBe().';
|
||||
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
var result = {
|
||||
const result = {
|
||||
pass: actual === expected
|
||||
};
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ getJasmineRequireObj().toBeCloseTo = function() {
|
||||
};
|
||||
}
|
||||
|
||||
var pow = Math.pow(10, precision + 1);
|
||||
var delta = Math.abs(expected - actual);
|
||||
var maxDelta = Math.pow(10, -precision) / 2;
|
||||
const pow = Math.pow(10, precision + 1);
|
||||
const delta = Math.abs(expected - actual);
|
||||
const maxDelta = Math.pow(10, -precision) / 2;
|
||||
|
||||
return {
|
||||
pass: Math.round(delta * pow) <= maxDelta * pow
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
getJasmineRequireObj().toBeInstanceOf = function(j$) {
|
||||
var usageError = j$.formatErrorMsg(
|
||||
const usageError = j$.formatErrorMsg(
|
||||
'<toBeInstanceOf>',
|
||||
'expect(value).toBeInstanceOf(<ConstructorFunction>)'
|
||||
);
|
||||
@@ -18,15 +18,15 @@ getJasmineRequireObj().toBeInstanceOf = function(j$) {
|
||||
function toBeInstanceOf(matchersUtil) {
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
var actualType =
|
||||
actual && actual.constructor
|
||||
? j$.fnNameFor(actual.constructor)
|
||||
: matchersUtil.pp(actual),
|
||||
expectedType = expected
|
||||
? j$.fnNameFor(expected)
|
||||
: matchersUtil.pp(expected),
|
||||
expectedMatcher,
|
||||
pass;
|
||||
const actualType =
|
||||
actual && actual.constructor
|
||||
? j$.fnNameFor(actual.constructor)
|
||||
: matchersUtil.pp(actual);
|
||||
const expectedType = expected
|
||||
? j$.fnNameFor(expected)
|
||||
: matchersUtil.pp(expected);
|
||||
let expectedMatcher;
|
||||
let pass;
|
||||
|
||||
try {
|
||||
expectedMatcher = new j$.Any(expected);
|
||||
|
||||
@@ -10,7 +10,7 @@ getJasmineRequireObj().toBeNaN = function(j$) {
|
||||
function toBeNaN(matchersUtil) {
|
||||
return {
|
||||
compare: function(actual) {
|
||||
var result = {
|
||||
const result = {
|
||||
pass: actual !== actual
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ getJasmineRequireObj().toBeNegativeInfinity = function(j$) {
|
||||
function toBeNegativeInfinity(matchersUtil) {
|
||||
return {
|
||||
compare: function(actual) {
|
||||
var result = {
|
||||
const result = {
|
||||
pass: actual === Number.NEGATIVE_INFINITY
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ getJasmineRequireObj().toBePositiveInfinity = function(j$) {
|
||||
function toBePositiveInfinity(matchersUtil) {
|
||||
return {
|
||||
compare: function(actual) {
|
||||
var result = {
|
||||
const result = {
|
||||
pass: actual === Number.POSITIVE_INFINITY
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ getJasmineRequireObj().toEqual = function(j$) {
|
||||
function toEqual(matchersUtil) {
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
var result = {
|
||||
const result = {
|
||||
pass: false
|
||||
},
|
||||
diffBuilder = new j$.DiffBuilder({ prettyPrinter: matchersUtil.pp });
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
getJasmineRequireObj().toHaveBeenCalled = function(j$) {
|
||||
var getErrorMsg = j$.formatErrorMsg(
|
||||
const getErrorMsg = j$.formatErrorMsg(
|
||||
'<toHaveBeenCalled>',
|
||||
'expect(<spyObj>).toHaveBeenCalled()'
|
||||
);
|
||||
@@ -16,7 +16,7 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) {
|
||||
function toHaveBeenCalled(matchersUtil) {
|
||||
return {
|
||||
compare: function(actual) {
|
||||
var result = {};
|
||||
const result = {};
|
||||
|
||||
if (!j$.isSpy(actual)) {
|
||||
throw new Error(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
|
||||
var getErrorMsg = j$.formatErrorMsg(
|
||||
const getErrorMsg = j$.formatErrorMsg(
|
||||
'<toHaveBeenCalledBefore>',
|
||||
'expect(<spyObj>).toHaveBeenCalledBefore(<spyObj>)'
|
||||
);
|
||||
@@ -31,7 +31,7 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
|
||||
);
|
||||
}
|
||||
|
||||
var result = { pass: false };
|
||||
const result = { pass: false };
|
||||
|
||||
if (!firstSpy.calls.count()) {
|
||||
result.message =
|
||||
@@ -44,8 +44,8 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
|
||||
return result;
|
||||
}
|
||||
|
||||
var latest1stSpyCall = firstSpy.calls.mostRecent().invocationOrder;
|
||||
var first2ndSpyCall = latterSpy.calls.first().invocationOrder;
|
||||
const latest1stSpyCall = firstSpy.calls.mostRecent().invocationOrder;
|
||||
const first2ndSpyCall = latterSpy.calls.first().invocationOrder;
|
||||
|
||||
result.pass = latest1stSpyCall < first2ndSpyCall;
|
||||
|
||||
@@ -57,8 +57,8 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
|
||||
latterSpy.and.identity +
|
||||
', but it was';
|
||||
} else {
|
||||
var first1stSpyCall = firstSpy.calls.first().invocationOrder;
|
||||
var latest2ndSpyCall = latterSpy.calls.mostRecent().invocationOrder;
|
||||
const first1stSpyCall = firstSpy.calls.first().invocationOrder;
|
||||
const latest2ndSpyCall = latterSpy.calls.mostRecent().invocationOrder;
|
||||
|
||||
if (first1stSpyCall < first2ndSpyCall) {
|
||||
result.message =
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) {
|
||||
var getErrorMsg = j$.formatErrorMsg(
|
||||
const getErrorMsg = j$.formatErrorMsg(
|
||||
'<toHaveBeenCalledOnceWith>',
|
||||
'expect(<spyObj>).toHaveBeenCalledOnceWith(...arguments)'
|
||||
);
|
||||
@@ -16,7 +16,7 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) {
|
||||
function toHaveBeenCalledOnceWith(util) {
|
||||
return {
|
||||
compare: function() {
|
||||
var args = Array.prototype.slice.call(arguments, 0),
|
||||
const args = Array.prototype.slice.call(arguments, 0),
|
||||
actual = args[0],
|
||||
expectedArgs = args.slice(1);
|
||||
|
||||
@@ -26,7 +26,7 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) {
|
||||
);
|
||||
}
|
||||
|
||||
var prettyPrintedCalls = actual.calls
|
||||
const prettyPrintedCalls = actual.calls
|
||||
.allArgs()
|
||||
.map(function(argsForCall) {
|
||||
return ' ' + util.pp(argsForCall);
|
||||
@@ -53,7 +53,7 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) {
|
||||
|
||||
function getDiffs() {
|
||||
return actual.calls.allArgs().map(function(argsForCall, callIx) {
|
||||
var diffBuilder = new j$.DiffBuilder();
|
||||
const diffBuilder = new j$.DiffBuilder();
|
||||
util.equals(argsForCall, expectedArgs, diffBuilder);
|
||||
return diffBuilder.getMessage();
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
||||
var getErrorMsg = j$.formatErrorMsg(
|
||||
const getErrorMsg = j$.formatErrorMsg(
|
||||
'<toHaveBeenCalledTimes>',
|
||||
'expect(<spyObj>).toHaveBeenCalledTimes(<Number>)'
|
||||
);
|
||||
@@ -24,7 +24,7 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
||||
);
|
||||
}
|
||||
|
||||
var args = Array.prototype.slice.call(arguments, 0),
|
||||
const args = Array.prototype.slice.call(arguments, 0),
|
||||
result = { pass: false };
|
||||
|
||||
if (!j$.isNumber_(expected)) {
|
||||
@@ -36,8 +36,8 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
||||
}
|
||||
|
||||
actual = args[0];
|
||||
var calls = actual.calls.count();
|
||||
var timesMessage = expected === 1 ? 'once' : expected + ' times';
|
||||
const calls = actual.calls.count();
|
||||
const timesMessage = expected === 1 ? 'once' : expected + ' times';
|
||||
result.pass = calls === expected;
|
||||
result.message = result.pass
|
||||
? 'Expected spy ' +
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
||||
var getErrorMsg = j$.formatErrorMsg(
|
||||
const getErrorMsg = j$.formatErrorMsg(
|
||||
'<toHaveBeenCalledWith>',
|
||||
'expect(<spyObj>).toHaveBeenCalledWith(...arguments)'
|
||||
);
|
||||
@@ -16,7 +16,7 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
||||
function toHaveBeenCalledWith(matchersUtil) {
|
||||
return {
|
||||
compare: function() {
|
||||
var args = Array.prototype.slice.call(arguments, 0),
|
||||
const args = Array.prototype.slice.call(arguments, 0),
|
||||
actual = args[0],
|
||||
expectedArgs = args.slice(1),
|
||||
result = { pass: false };
|
||||
@@ -57,16 +57,16 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
||||
};
|
||||
} else {
|
||||
result.message = function() {
|
||||
var prettyPrintedCalls = actual.calls
|
||||
const prettyPrintedCalls = actual.calls
|
||||
.allArgs()
|
||||
.map(function(argsForCall) {
|
||||
return ' ' + matchersUtil.pp(argsForCall);
|
||||
});
|
||||
|
||||
var diffs = actual.calls
|
||||
const diffs = actual.calls
|
||||
.allArgs()
|
||||
.map(function(argsForCall, callIx) {
|
||||
var diffBuilder = new j$.DiffBuilder();
|
||||
const diffBuilder = new j$.DiffBuilder();
|
||||
matchersUtil.equals(argsForCall, expectedArgs, diffBuilder);
|
||||
return (
|
||||
'Call ' +
|
||||
|
||||
@@ -12,7 +12,7 @@ getJasmineRequireObj().toHaveSize = function(j$) {
|
||||
function toHaveSize() {
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
var result = {
|
||||
const result = {
|
||||
pass: false
|
||||
};
|
||||
|
||||
@@ -37,7 +37,7 @@ getJasmineRequireObj().toHaveSize = function(j$) {
|
||||
};
|
||||
}
|
||||
|
||||
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
||||
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
||||
function isLength(value) {
|
||||
return (
|
||||
typeof value == 'number' &&
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
getJasmineRequireObj().toHaveSpyInteractions = function(j$) {
|
||||
var getErrorMsg = j$.formatErrorMsg(
|
||||
const getErrorMsg = j$.formatErrorMsg(
|
||||
'<toHaveSpyInteractions>',
|
||||
'expect(<spyObj>).toHaveSpyInteractions()'
|
||||
);
|
||||
@@ -16,7 +16,7 @@ getJasmineRequireObj().toHaveSpyInteractions = function(j$) {
|
||||
function toHaveSpyInteractions(matchersUtil) {
|
||||
return {
|
||||
compare: function(actual) {
|
||||
var result = {};
|
||||
const result = {};
|
||||
|
||||
if (!j$.isObject_(actual)) {
|
||||
throw new Error(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
getJasmineRequireObj().toMatch = function(j$) {
|
||||
var getErrorMsg = j$.formatErrorMsg(
|
||||
const getErrorMsg = j$.formatErrorMsg(
|
||||
'<toMatch>',
|
||||
'expect(<expectation>).toMatch(<string> || <regexp>)'
|
||||
);
|
||||
@@ -21,7 +21,7 @@ getJasmineRequireObj().toMatch = function(j$) {
|
||||
throw new Error(getErrorMsg('Expected is not a String or a RegExp'));
|
||||
}
|
||||
|
||||
var regexp = new RegExp(expected);
|
||||
const regexp = new RegExp(expected);
|
||||
|
||||
return {
|
||||
pass: regexp.test(actual)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
getJasmineRequireObj().toThrow = function(j$) {
|
||||
var getErrorMsg = j$.formatErrorMsg(
|
||||
const getErrorMsg = j$.formatErrorMsg(
|
||||
'<toThrow>',
|
||||
'expect(function() {<expectation>}).toThrow()'
|
||||
);
|
||||
@@ -17,9 +17,9 @@ getJasmineRequireObj().toThrow = function(j$) {
|
||||
function toThrow(matchersUtil) {
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
var result = { pass: false },
|
||||
threw = false,
|
||||
thrown;
|
||||
const result = { pass: false };
|
||||
let threw = false;
|
||||
let thrown;
|
||||
|
||||
if (typeof actual != 'function') {
|
||||
throw new Error(getErrorMsg('Actual is not a Function'));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
getJasmineRequireObj().toThrowError = function(j$) {
|
||||
var getErrorMsg = j$.formatErrorMsg(
|
||||
const getErrorMsg = j$.formatErrorMsg(
|
||||
'<toThrowError>',
|
||||
'expect(function() {<expectation>}).toThrowError(<ErrorConstructor>, <message>)'
|
||||
);
|
||||
@@ -21,13 +21,14 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
function toThrowError(matchersUtil) {
|
||||
return {
|
||||
compare: function(actual) {
|
||||
var errorMatcher = getMatcher.apply(null, arguments),
|
||||
thrown;
|
||||
const errorMatcher = getMatcher.apply(null, arguments);
|
||||
|
||||
if (typeof actual != 'function') {
|
||||
throw new Error(getErrorMsg('Actual is not a Function'));
|
||||
}
|
||||
|
||||
let thrown;
|
||||
|
||||
try {
|
||||
actual();
|
||||
return fail('Expected function to throw an Error.');
|
||||
@@ -50,7 +51,7 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
};
|
||||
|
||||
function getMatcher() {
|
||||
var expected, errorType;
|
||||
let expected, errorType;
|
||||
|
||||
if (arguments[2]) {
|
||||
errorType = arguments[1];
|
||||
@@ -106,15 +107,15 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
}
|
||||
}
|
||||
|
||||
var errorTypeDescription = errorType
|
||||
const errorTypeDescription = errorType
|
||||
? j$.fnNameFor(errorType)
|
||||
: 'an exception';
|
||||
|
||||
function thrownDescription(thrown) {
|
||||
var thrownName = errorType
|
||||
? j$.fnNameFor(thrown.constructor)
|
||||
: 'an exception',
|
||||
thrownMessage = '';
|
||||
const thrownName = errorType
|
||||
? j$.fnNameFor(thrown.constructor)
|
||||
: 'an exception';
|
||||
let thrownMessage = '';
|
||||
|
||||
if (expected) {
|
||||
thrownMessage = ' with message ' + matchersUtil.pp(thrown.message);
|
||||
@@ -176,7 +177,7 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var Surrogate = function() {};
|
||||
const Surrogate = function() {};
|
||||
Surrogate.prototype = type.prototype;
|
||||
return j$.isError_(new Surrogate());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
getJasmineRequireObj().toThrowMatching = function(j$) {
|
||||
var usageError = j$.formatErrorMsg(
|
||||
const usageError = j$.formatErrorMsg(
|
||||
'<toThrowMatching>',
|
||||
'expect(function() {<expectation>}).toThrowMatching(<Predicate>)'
|
||||
);
|
||||
@@ -16,8 +16,6 @@ getJasmineRequireObj().toThrowMatching = function(j$) {
|
||||
function toThrowMatching(matchersUtil) {
|
||||
return {
|
||||
compare: function(actual, predicate) {
|
||||
var thrown;
|
||||
|
||||
if (typeof actual !== 'function') {
|
||||
throw new Error(usageError('Actual is not a Function'));
|
||||
}
|
||||
@@ -26,6 +24,8 @@ getJasmineRequireObj().toThrowMatching = function(j$) {
|
||||
throw new Error(usageError('Predicate is not a Function'));
|
||||
}
|
||||
|
||||
let thrown;
|
||||
|
||||
try {
|
||||
actual();
|
||||
return fail('Expected function to throw an exception.');
|
||||
|
||||
Reference in New Issue
Block a user