diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index f86e9f55..919bdf5d 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -2369,12 +2369,11 @@ getJasmineRequireObj().JsApiReporter = function(j$) { }; getJasmineRequireObj().Any = function(j$) { - function Any(expectedObject) { if (typeof expectedObject === 'undefined') { throw new TypeError( 'jasmine.any() expects to be passed a constructor function. ' + - 'Please pass one or use jasmine.anything() to match any object.' + 'Please pass one or use jasmine.anything() to match any object.' ); } this.expectedObject = expectedObject; @@ -2419,7 +2418,6 @@ getJasmineRequireObj().Any = function(j$) { }; getJasmineRequireObj().Anything = function(j$) { - function Anything() {} Anything.prototype.asymmetricMatch = function(other) { @@ -2440,7 +2438,11 @@ getJasmineRequireObj().ArrayContaining = function(j$) { 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) + '.'); + throw new Error( + 'You must provide an array to arrayContaining, not ' + + j$.pp(this.sample) + + '.' + ); } // If the actual parameter is not an array, we can fail immediately, since it couldn't @@ -2460,22 +2462,28 @@ getJasmineRequireObj().ArrayContaining = function(j$) { return true; }; - ArrayContaining.prototype.jasmineToString = function (pp) { - return ''; + ArrayContaining.prototype.jasmineToString = function(pp) { + return ''; }; return ArrayContaining; }; getJasmineRequireObj().ArrayWithExactContents = function(j$) { - function ArrayWithExactContents(sample) { this.sample = sample; } - ArrayWithExactContents.prototype.asymmetricMatch = function(other, matchersUtil) { + 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) + '.'); + throw new Error( + 'You must provide an array to arrayWithExactContents, not ' + + j$.pp(this.sample) + + '.' + ); } if (this.sample.length !== other.length) { @@ -2499,11 +2507,10 @@ getJasmineRequireObj().ArrayWithExactContents = function(j$) { return ArrayWithExactContents; }; -getJasmineRequireObj().Empty = function (j$) { - +getJasmineRequireObj().Empty = function(j$) { function Empty() {} - Empty.prototype.asymmetricMatch = function (other) { + Empty.prototype.asymmetricMatch = function(other) { if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) { return other.length === 0; } @@ -2518,7 +2525,7 @@ getJasmineRequireObj().Empty = function (j$) { return false; }; - Empty.prototype.jasmineToString = function () { + Empty.prototype.jasmineToString = function() { return ''; }; @@ -2526,7 +2533,6 @@ getJasmineRequireObj().Empty = function (j$) { }; getJasmineRequireObj().Falsy = function(j$) { - function Falsy() {} Falsy.prototype.asymmetricMatch = function(other) { @@ -2543,7 +2549,9 @@ getJasmineRequireObj().Falsy = function(j$) { getJasmineRequireObj().MapContaining = function(j$) { function MapContaining(sample) { if (!j$.isMap(sample)) { - throw new Error('You must provide a map to `mapContaining`, not ' + j$.pp(sample)); + throw new Error( + 'You must provide a map to `mapContaining`, not ' + j$.pp(sample) + ); } this.sample = sample; @@ -2559,8 +2567,8 @@ getJasmineRequireObj().MapContaining = function(j$) { var hasMatch = false; j$.util.forEachBreakable(other, function(oBreakLoop, oValue, oKey) { if ( - matchersUtil.equals(oKey, key) - && matchersUtil.equals(oValue, value) + matchersUtil.equals(oKey, key) && + matchersUtil.equals(oValue, value) ) { hasMatch = true; oBreakLoop(); @@ -2582,11 +2590,10 @@ getJasmineRequireObj().MapContaining = function(j$) { return MapContaining; }; -getJasmineRequireObj().NotEmpty = function (j$) { - +getJasmineRequireObj().NotEmpty = function(j$) { function NotEmpty() {} - NotEmpty.prototype.asymmetricMatch = function (other) { + NotEmpty.prototype.asymmetricMatch = function(other) { if (j$.isString_(other) || j$.isArray_(other) || j$.isTypedArray_(other)) { return other.length !== 0; } @@ -2602,7 +2609,7 @@ getJasmineRequireObj().NotEmpty = function (j$) { return false; }; - NotEmpty.prototype.jasmineToString = function () { + NotEmpty.prototype.jasmineToString = function() { return ''; }; @@ -2610,7 +2617,6 @@ getJasmineRequireObj().NotEmpty = function (j$) { }; getJasmineRequireObj().ObjectContaining = function(j$) { - function ObjectContaining(sample) { this.sample = sample; } @@ -2628,7 +2634,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) { } function hasProperty(obj, property) { - if (!obj || typeof(obj) !== 'object') { + if (!obj || typeof obj !== 'object') { return false; } @@ -2640,12 +2646,22 @@ getJasmineRequireObj().ObjectContaining = function(j$) { } 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; } + 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) || - !matchersUtil.equals(this.sample[property], other[property])) { + if ( + !hasProperty(other, property) || + !matchersUtil.equals(this.sample[property], other[property]) + ) { return false; } } @@ -2662,7 +2678,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) { } var filteredOther = {}; - Object.keys(this.sample).forEach(function (k) { + Object.keys(this.sample).forEach(function(k) { // eq short-circuits comparison of objects that have different key sets, // so include all keys even if undefined. filteredOther[k] = other[k]; @@ -2684,7 +2700,9 @@ getJasmineRequireObj().ObjectContaining = function(j$) { getJasmineRequireObj().SetContaining = function(j$) { function SetContaining(sample) { if (!j$.isSet(sample)) { - throw new Error('You must provide a set to `setContaining`, not ' + j$.pp(sample)); + throw new Error( + 'You must provide a set to `setContaining`, not ' + j$.pp(sample) + ); } this.sample = sample; @@ -2722,7 +2740,6 @@ getJasmineRequireObj().SetContaining = function(j$) { }; getJasmineRequireObj().StringMatching = function(j$) { - function StringMatching(expected) { if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) { throw new Error('Expected is not a String or a RegExp'); @@ -2743,7 +2760,6 @@ getJasmineRequireObj().StringMatching = function(j$) { }; getJasmineRequireObj().Truthy = function(j$) { - function Truthy() {} Truthy.prototype.asymmetricMatch = function(other) { @@ -4164,8 +4180,12 @@ getJasmineRequireObj().toBePending = function(j$) { } var want = {}; return Promise.race([actual, Promise.resolve(want)]).then( - function(got) { return {pass: want === got}; }, - function() { return {pass: false}; } + function(got) { + return { pass: want === got }; + }, + function() { + return { pass: false }; + } ); } }; @@ -4191,8 +4211,12 @@ getJasmineRequireObj().toBeRejected = function(j$) { throw new Error('Expected toBeRejected to be called on a promise.'); } return actual.then( - function() { return {pass: false}; }, - function() { return {pass: true}; } + function() { + return { pass: false }; + }, + function() { + return { pass: true }; + } ); } }; @@ -4216,35 +4240,44 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) { return { compare: function(actualPromise, expectedValue) { if (!j$.isPromiseLike(actualPromise)) { - throw new Error('Expected toBeRejectedWith to be called on a promise.'); + throw new Error( + 'Expected toBeRejectedWith to be called on a promise.' + ); } function prefix(passed) { - return 'Expected a promise ' + + return ( + 'Expected a promise ' + (passed ? 'not ' : '') + - 'to be rejected with ' + matchersUtil.pp(expectedValue); + 'to be rejected with ' + + matchersUtil.pp(expectedValue) + ); } return actualPromise.then( function() { - return { - pass: false, - message: prefix(false) + ' but it was resolved.' - }; - }, - function(actualValue) { - if (matchersUtil.equals(actualValue, expectedValue)) { - return { - pass: true, - message: prefix(true) + '.' - }; - } else { return { pass: false, - message: prefix(false) + ' but it was rejected with ' + matchersUtil.pp(actualValue) + '.' + message: prefix(false) + ' but it was resolved.' }; + }, + function(actualValue) { + if (matchersUtil.equals(actualValue, expectedValue)) { + return { + pass: true, + message: prefix(true) + '.' + }; + } else { + return { + pass: false, + message: + prefix(false) + + ' but it was rejected with ' + + matchersUtil.pp(actualValue) + + '.' + }; + } } - } ); } }; @@ -4271,7 +4304,9 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { return { compare: function(actualPromise, arg1, arg2) { if (!j$.isPromiseLike(actualPromise)) { - throw new Error('Expected toBeRejectedWithError to be called on a promise.'); + throw new Error( + 'Expected toBeRejectedWithError to be called on a promise.' + ); } var expected = getExpectedFromArgs(arg1, arg2, matchersUtil); @@ -4283,7 +4318,9 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { message: 'Expected a promise to be rejected but it was resolved.' }; }, - function(actualValue) { return matchError(actualValue, expected, matchersUtil); } + function(actualValue) { + return matchError(actualValue, expected, matchersUtil); + } ); } }; @@ -4295,16 +4332,25 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { } if (!(actual instanceof expected.error)) { - return fail(expected, 'rejected with type ' + j$.fnNameFor(actual.constructor)); + return fail( + expected, + 'rejected with type ' + j$.fnNameFor(actual.constructor) + ); } var actualMessage = actual.message; - if (actualMessage === expected.message || typeof expected.message === 'undefined') { + if ( + actualMessage === expected.message || + typeof expected.message === 'undefined' + ) { return pass(expected); } - if (expected.message instanceof RegExp && expected.message.test(actualMessage)) { + if ( + expected.message instanceof RegExp && + expected.message.test(actualMessage) + ) { return pass(expected); } @@ -4314,18 +4360,25 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { function pass(expected) { return { pass: true, - message: 'Expected a promise not to be rejected with ' + expected.printValue + ', but it was.' + message: + 'Expected a promise not to be rejected with ' + + expected.printValue + + ', but it was.' }; } function fail(expected, message) { return { pass: false, - message: 'Expected a promise to be rejected with ' + expected.printValue + ' but it was ' + message + '.' + message: + 'Expected a promise to be rejected with ' + + expected.printValue + + ' but it was ' + + message + + '.' }; } - function getExpectedFromArgs(arg1, arg2, matchersUtil) { var error, message; @@ -4340,12 +4393,17 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) { return { error: error, message: message, - printValue: j$.fnNameFor(error) + (typeof message === 'undefined' ? '' : ': ' + matchersUtil.pp(message)) + printValue: + j$.fnNameFor(error) + + (typeof message === 'undefined' ? '' : ': ' + matchersUtil.pp(message)) }; } function isErrorConstructor(value) { - return typeof value === 'function' && (value === Error || j$.isError_(value.prototype)); + return ( + typeof value === 'function' && + (value === Error || j$.isError_(value.prototype)) + ); } }; @@ -4369,8 +4427,12 @@ getJasmineRequireObj().toBeResolved = function(j$) { } return actual.then( - function() { return {pass: true}; }, - function() { return {pass: false}; } + function() { + return { pass: true }; + }, + function() { + return { pass: false }; + } ); } }; @@ -4398,9 +4460,12 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) { } function prefix(passed) { - return 'Expected a promise ' + + return ( + 'Expected a promise ' + (passed ? 'not ' : '') + - 'to be resolved to ' + matchersUtil.pp(expectedValue); + 'to be resolved to ' + + matchersUtil.pp(expectedValue) + ); } return actualPromise.then( @@ -4413,7 +4478,11 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) { } else { return { pass: false, - message: prefix(false) + ' but it was resolved to ' + matchersUtil.pp(actualValue) + '.' + message: + prefix(false) + + ' but it was resolved to ' + + matchersUtil.pp(actualValue) + + '.' }; } }, @@ -4429,7 +4498,7 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) { }; }; -getJasmineRequireObj().DiffBuilder = function (j$) { +getJasmineRequireObj().DiffBuilder = function(j$) { return function DiffBuilder(config) { var prettyPrinter = (config || {}).prettyPrinter || j$.makePrettyPrinter(), mismatches = new j$.MismatchTree(), @@ -4438,21 +4507,28 @@ getJasmineRequireObj().DiffBuilder = function (j$) { expectedRoot = undefined; return { - setRoots: function (actual, expected) { + setRoots: function(actual, expected) { actualRoot = actual; expectedRoot = expected; }, - recordMismatch: function (formatter) { + recordMismatch: function(formatter) { mismatches.add(path, formatter); }, - getMessage: function () { + getMessage: function() { var messages = []; - mismatches.traverse(function (path, isLeaf, formatter) { - var actualCustom, expectedCustom, useCustom, - derefResult = dereferencePath(path, actualRoot, expectedRoot, prettyPrinter), + mismatches.traverse(function(path, isLeaf, formatter) { + var actualCustom, + expectedCustom, + useCustom, + derefResult = dereferencePath( + path, + actualRoot, + expectedRoot, + prettyPrinter + ), actual = derefResult.actual, expected = derefResult.expected; @@ -4463,15 +4539,22 @@ getJasmineRequireObj().DiffBuilder = function (j$) { actualCustom = prettyPrinter.customFormat_(actual); expectedCustom = prettyPrinter.customFormat_(expected); - useCustom = !(j$.util.isUndefined(actualCustom) && j$.util.isUndefined(expectedCustom)); + useCustom = !( + j$.util.isUndefined(actualCustom) && + j$.util.isUndefined(expectedCustom) + ); if (useCustom) { - messages.push(wrapPrettyPrinted(actualCustom, expectedCustom, path)); + messages.push( + wrapPrettyPrinted(actualCustom, expectedCustom, path) + ); return false; // don't recurse further } if (isLeaf) { - messages.push(defaultFormatter(actual, expected, path, prettyPrinter)); + messages.push( + defaultFormatter(actual, expected, path, prettyPrinter) + ); } return true; @@ -4480,7 +4563,7 @@ getJasmineRequireObj().DiffBuilder = function (j$) { return messages.join('\n'); }, - withPath: function (pathComponent, block) { + withPath: function(pathComponent, block) { var oldPath = path; path = path.add(pathComponent); block(); @@ -4489,22 +4572,32 @@ getJasmineRequireObj().DiffBuilder = function (j$) { }; function defaultFormatter(actual, expected, path, prettyPrinter) { - return wrapPrettyPrinted(prettyPrinter(actual), prettyPrinter(expected), path); + return wrapPrettyPrinted( + prettyPrinter(actual), + prettyPrinter(expected), + path + ); } function wrapPrettyPrinted(actual, expected, path) { - return 'Expected ' + - path + (path.depth() ? ' = ' : '') + + return ( + 'Expected ' + + path + + (path.depth() ? ' = ' : '') + actual + ' to equal ' + expected + - '.'; + '.' + ); } }; function dereferencePath(objectPath, actual, expected, pp) { function handleAsymmetricExpected() { - if (j$.isAsymmetricEqualityTester_(expected) && j$.isFunction_(expected.valuesForDiff_)) { + if ( + j$.isAsymmetricEqualityTester_(expected) && + j$.isFunction_(expected.valuesForDiff_) + ) { var asymmetricResult = expected.valuesForDiff_(actual, pp); expected = asymmetricResult.self; actual = asymmetricResult.other; @@ -4520,9 +4613,8 @@ getJasmineRequireObj().DiffBuilder = function (j$) { handleAsymmetricExpected(); } - return {actual: actual, expected: expected}; + return { actual: actual, expected: expected }; } - }; getJasmineRequireObj().MatchersUtil = function(j$) { @@ -4548,7 +4640,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 @@ -4566,9 +4658,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; @@ -4587,9 +4680,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; @@ -4606,20 +4702,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; @@ -4654,7 +4771,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)) { @@ -4673,10 +4795,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; } @@ -4734,7 +4872,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(); } @@ -4751,10 +4890,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(); @@ -4788,7 +4929,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); @@ -4810,10 +4953,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; } }); } @@ -4828,11 +4981,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. @@ -4853,13 +5006,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() + ); } } @@ -4874,12 +5044,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 @@ -4903,7 +5073,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); @@ -4918,27 +5095,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; } @@ -4946,13 +5131,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; } }); @@ -4970,23 +5159,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 = []; @@ -5005,21 +5195,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'); @@ -5030,17 +5224,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) { @@ -5058,8 +5260,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) { return MatchersUtil; }; -getJasmineRequireObj().MismatchTree = function (j$) { - +getJasmineRequireObj().MismatchTree = function(j$) { /* To be able to apply custom object formatters at all possible levels of an object graph, DiffBuilder needs to be able to know not just where the @@ -5074,7 +5275,7 @@ getJasmineRequireObj().MismatchTree = function (j$) { this.isMismatch = false; } - MismatchTree.prototype.add = function (path, formatter) { + MismatchTree.prototype.add = function(path, formatter) { var key, child; if (path.depth() === 0) { @@ -5094,8 +5295,9 @@ getJasmineRequireObj().MismatchTree = function (j$) { } }; - MismatchTree.prototype.traverse = function (visit) { - var i, hasChildren = this.children.length > 0; + MismatchTree.prototype.traverse = function(visit) { + var i, + hasChildren = this.children.length > 0; if (this.isMismatch || hasChildren) { if (visit(this.path, !hasChildren, this.formatter)) { @@ -5120,7 +5322,6 @@ getJasmineRequireObj().MismatchTree = function (j$) { return MismatchTree; }; - getJasmineRequireObj().nothing = function() { /** * {@link expect} nothing explicitly. @@ -5189,7 +5390,7 @@ getJasmineRequireObj().ObjectPath = function(j$) { return '.' + prop; } - return '[\'' + prop + '\']'; + return "['" + prop + "']"; } function map(array, fn) { @@ -5237,7 +5438,8 @@ getJasmineRequireObj().toBe = function(j$) { * expect(thing).toBe(realThing); */ function toBe(matchersUtil) { - var tip = ' Tip: To check for deep equality, use .toEqual() instead of .toBe().'; + var tip = + ' Tip: To check for deep equality, use .toEqual() instead of .toBe().'; return { compare: function(actual, expected) { @@ -5246,7 +5448,13 @@ getJasmineRequireObj().toBe = function(j$) { }; if (typeof expected === 'object') { - result.message = matchersUtil.buildFailureMessage('toBe', result.pass, actual, expected) + tip; + result.message = + matchersUtil.buildFailureMessage( + 'toBe', + result.pass, + actual, + expected + ) + tip; } return result; @@ -5276,8 +5484,13 @@ getJasmineRequireObj().toBeCloseTo = function() { } if (expected === null || actual === null) { - throw new Error('Cannot use toBeCloseTo with null. Arguments evaluated to: ' + - 'expect(' + actual + ').toBeCloseTo(' + expected + ').' + throw new Error( + 'Cannot use toBeCloseTo with null. Arguments evaluated to: ' + + 'expect(' + + actual + + ').toBeCloseTo(' + + expected + + ').' ); } @@ -5308,7 +5521,7 @@ getJasmineRequireObj().toBeDefined = function() { return { compare: function(actual) { return { - pass: (void 0 !== actual) + pass: void 0 !== actual }; } }; @@ -5384,7 +5597,6 @@ getJasmineRequireObj().toBeGreaterThan = function() { return toBeGreaterThan; }; - getJasmineRequireObj().toBeGreaterThanOrEqual = function() { /** * {@link expect} the actual value to be greater than or equal to the expected value. @@ -5409,7 +5621,10 @@ getJasmineRequireObj().toBeGreaterThanOrEqual = function() { }; getJasmineRequireObj().toBeInstanceOf = function(j$) { - var usageError = j$.formatErrorMsg('', 'expect(value).toBeInstanceOf()'); + var usageError = j$.formatErrorMsg( + '', + 'expect(value).toBeInstanceOf()' + ); /** * {@link expect} the actual to be an instance of the expected class @@ -5425,27 +5640,42 @@ 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; + var actualType = + actual && actual.constructor + ? j$.fnNameFor(actual.constructor) + : matchersUtil.pp(actual), + expectedType = expected + ? j$.fnNameFor(expected) + : matchersUtil.pp(expected), + expectedMatcher, + pass; try { - expectedMatcher = new j$.Any(expected); - pass = expectedMatcher.asymmetricMatch(actual); + expectedMatcher = new j$.Any(expected); + pass = expectedMatcher.asymmetricMatch(actual); } catch (error) { - throw new Error(usageError('Expected value is not a constructor function')); + throw new Error( + usageError('Expected value is not a constructor function') + ); } if (pass) { return { pass: true, - message: 'Expected instance of ' + actualType + ' not to be an instance of ' + expectedType + message: + 'Expected instance of ' + + actualType + + ' not to be an instance of ' + + expectedType }; } else { return { pass: false, - message: 'Expected instance of ' + actualType + ' to be an instance of ' + expectedType + message: + 'Expected instance of ' + + actualType + + ' to be an instance of ' + + expectedType }; } } @@ -5467,7 +5697,6 @@ getJasmineRequireObj().toBeLessThan = function() { */ function toBeLessThan() { return { - compare: function(actual, expected) { return { pass: actual < expected @@ -5491,7 +5720,6 @@ getJasmineRequireObj().toBeLessThanOrEqual = function() { */ function toBeLessThanOrEqual() { return { - compare: function(actual, expected) { return { pass: actual <= expected @@ -5516,13 +5744,15 @@ getJasmineRequireObj().toBeNaN = function(j$) { return { compare: function(actual) { var result = { - pass: (actual !== actual) + pass: actual !== actual }; if (result.pass) { result.message = 'Expected actual not to be NaN.'; } else { - result.message = function() { return 'Expected ' + matchersUtil.pp(actual) + ' to be NaN.'; }; + result.message = function() { + return 'Expected ' + matchersUtil.pp(actual) + ' to be NaN.'; + }; } return result; @@ -5546,13 +5776,15 @@ getJasmineRequireObj().toBeNegativeInfinity = function(j$) { return { compare: function(actual) { var result = { - pass: (actual === Number.NEGATIVE_INFINITY) + pass: actual === Number.NEGATIVE_INFINITY }; if (result.pass) { result.message = 'Expected actual not to be -Infinity.'; } else { - result.message = function() { return 'Expected ' + matchersUtil.pp(actual) + ' to be -Infinity.'; }; + result.message = function() { + return 'Expected ' + matchersUtil.pp(actual) + ' to be -Infinity.'; + }; } return result; @@ -5598,13 +5830,15 @@ getJasmineRequireObj().toBePositiveInfinity = function(j$) { return { compare: function(actual) { var result = { - pass: (actual === Number.POSITIVE_INFINITY) + pass: actual === Number.POSITIVE_INFINITY }; if (result.pass) { result.message = 'Expected actual not to be Infinity.'; } else { - result.message = function() { return 'Expected ' + matchersUtil.pp(actual) + ' to be Infinity.'; }; + result.message = function() { + return 'Expected ' + matchersUtil.pp(actual) + ' to be Infinity.'; + }; } return result; @@ -5695,7 +5929,6 @@ getJasmineRequireObj().toContain = function() { function toContain(matchersUtil) { return { compare: function(actual, expected) { - return { pass: matchersUtil.contains(actual, expected) }; @@ -5722,7 +5955,7 @@ getJasmineRequireObj().toEqual = function(j$) { var result = { pass: false }, - diffBuilder = j$.DiffBuilder({prettyPrinter: matchersUtil.pp}); + diffBuilder = j$.DiffBuilder({ prettyPrinter: matchersUtil.pp }); result.pass = matchersUtil.equals(actual, expected, diffBuilder); @@ -5738,8 +5971,10 @@ getJasmineRequireObj().toEqual = function(j$) { }; getJasmineRequireObj().toHaveBeenCalled = function(j$) { - - var getErrorMsg = j$.formatErrorMsg('', 'expect().toHaveBeenCalled()'); + var getErrorMsg = j$.formatErrorMsg( + '', + 'expect().toHaveBeenCalled()' + ); /** * {@link expect} the actual (a {@link Spy}) to have been called. @@ -5756,18 +5991,24 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) { var result = {}; if (!j$.isSpy(actual)) { - throw new Error(getErrorMsg('Expected a spy, but got ' + matchersUtil.pp(actual) + '.')); + throw new Error( + getErrorMsg( + 'Expected a spy, but got ' + matchersUtil.pp(actual) + '.' + ) + ); } if (arguments.length > 1) { - throw new Error(getErrorMsg('Does not take arguments, use toHaveBeenCalledWith')); + throw new Error( + getErrorMsg('Does not take arguments, use toHaveBeenCalledWith') + ); } result.pass = actual.calls.any(); - result.message = result.pass ? - 'Expected spy ' + actual.and.identity + ' not to have been called.' : - 'Expected spy ' + actual.and.identity + ' to have been called.'; + result.message = result.pass + ? 'Expected spy ' + actual.and.identity + ' not to have been called.' + : 'Expected spy ' + actual.and.identity + ' to have been called.'; return result; } @@ -5778,8 +6019,10 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) { }; getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) { - - var getErrorMsg = j$.formatErrorMsg('', 'expect().toHaveBeenCalledBefore()'); + var getErrorMsg = j$.formatErrorMsg( + '', + 'expect().toHaveBeenCalledBefore()' + ); /** * {@link expect} the actual value (a {@link Spy}) to have been called before another {@link Spy}. @@ -5794,20 +6037,30 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) { return { compare: function(firstSpy, latterSpy) { if (!j$.isSpy(firstSpy)) { - throw new Error(getErrorMsg('Expected a spy, but got ' + matchersUtil.pp(firstSpy) + '.')); + throw new Error( + getErrorMsg( + 'Expected a spy, but got ' + matchersUtil.pp(firstSpy) + '.' + ) + ); } if (!j$.isSpy(latterSpy)) { - throw new Error(getErrorMsg('Expected a spy, but got ' + matchersUtil.pp(latterSpy) + '.')); + throw new Error( + getErrorMsg( + 'Expected a spy, but got ' + matchersUtil.pp(latterSpy) + '.' + ) + ); } var result = { pass: false }; if (!firstSpy.calls.count()) { - result.message = 'Expected spy ' + firstSpy.and.identity + ' to have been called.'; + result.message = + 'Expected spy ' + firstSpy.and.identity + ' to have been called.'; return result; } if (!latterSpy.calls.count()) { - result.message = 'Expected spy ' + latterSpy.and.identity + ' to have been called.'; + result.message = + 'Expected spy ' + latterSpy.and.identity + ' to have been called.'; return result; } @@ -5817,17 +6070,36 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) { result.pass = latest1stSpyCall < first2ndSpyCall; if (result.pass) { - result.message = 'Expected spy ' + firstSpy.and.identity + ' to not have been called before spy ' + latterSpy.and.identity + ', but it was'; + result.message = + 'Expected spy ' + + firstSpy.and.identity + + ' to not have been called before spy ' + + latterSpy.and.identity + + ', but it was'; } else { var first1stSpyCall = firstSpy.calls.first().invocationOrder; var latest2ndSpyCall = latterSpy.calls.mostRecent().invocationOrder; - if(first1stSpyCall < first2ndSpyCall) { - result.message = 'Expected latest call to spy ' + firstSpy.and.identity + ' to have been called before first call to spy ' + latterSpy.and.identity + ' (no interleaved calls)'; + if (first1stSpyCall < first2ndSpyCall) { + result.message = + 'Expected latest call to spy ' + + firstSpy.and.identity + + ' to have been called before first call to spy ' + + latterSpy.and.identity + + ' (no interleaved calls)'; } else if (latest2ndSpyCall > latest1stSpyCall) { - result.message = 'Expected first call to spy ' + latterSpy.and.identity + ' to have been called after latest call to spy ' + firstSpy.and.identity + ' (no interleaved calls)'; + result.message = + 'Expected first call to spy ' + + latterSpy.and.identity + + ' to have been called after latest call to spy ' + + firstSpy.and.identity + + ' (no interleaved calls)'; } else { - result.message = 'Expected spy ' + firstSpy.and.identity + ' to have been called before spy ' + latterSpy.and.identity; + result.message = + 'Expected spy ' + + firstSpy.and.identity + + ' to have been called before spy ' + + latterSpy.and.identity; } } @@ -5839,9 +6111,11 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) { return toHaveBeenCalledBefore; }; -getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) { - - var getErrorMsg = j$.formatErrorMsg('', 'expect().toHaveBeenCalledOnceWith(...arguments)'); +getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) { + var getErrorMsg = j$.formatErrorMsg( + '', + 'expect().toHaveBeenCalledOnceWith(...arguments)' + ); /** * {@link expect} the actual (a {@link Spy}) to have been called exactly once, and exactly with the particular arguments. @@ -5854,31 +6128,44 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) { */ function toHaveBeenCalledOnceWith(util) { return { - compare: function () { + compare: function() { var args = Array.prototype.slice.call(arguments, 0), actual = args[0], expectedArgs = args.slice(1); if (!j$.isSpy(actual)) { - throw new Error(getErrorMsg('Expected a spy, but got ' + util.pp(actual) + '.')); + throw new Error( + getErrorMsg('Expected a spy, but got ' + util.pp(actual) + '.') + ); } - var prettyPrintedCalls = actual.calls.allArgs().map(function (argsForCall) { - return ' ' + util.pp(argsForCall); - }); + var prettyPrintedCalls = actual.calls + .allArgs() + .map(function(argsForCall) { + return ' ' + util.pp(argsForCall); + }); - if (actual.calls.count() === 1 && util.contains(actual.calls.allArgs(), expectedArgs)) { + if ( + actual.calls.count() === 1 && + util.contains(actual.calls.allArgs(), expectedArgs) + ) { return { pass: true, - message: 'Expected spy ' + actual.and.identity + ' to have been called 0 times, multiple times, or once, but with arguments different from:\n' - + ' ' + util.pp(expectedArgs) + '\n' - + 'But the actual call was:\n' - + prettyPrintedCalls.join(',\n') + '.\n\n' + message: + 'Expected spy ' + + actual.and.identity + + ' to have been called 0 times, multiple times, or once, but with arguments different from:\n' + + ' ' + + util.pp(expectedArgs) + + '\n' + + 'But the actual call was:\n' + + prettyPrintedCalls.join(',\n') + + '.\n\n' }; } function getDiffs() { - return actual.calls.allArgs().map(function (argsForCall, callIx) { + return actual.calls.allArgs().map(function(argsForCall, callIx) { var diffBuilder = new j$.DiffBuilder(); util.equals(argsForCall, expectedArgs, diffBuilder); return diffBuilder.getMessage(); @@ -5890,17 +6177,32 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) { case 0: return 'But it was never called.\n\n'; case 1: - return 'But the actual call was:\n' + prettyPrintedCalls.join(',\n') + '.\n' + getDiffs().join('\n') + '\n\n'; + return ( + 'But the actual call was:\n' + + prettyPrintedCalls.join(',\n') + + '.\n' + + getDiffs().join('\n') + + '\n\n' + ); default: - return 'But the actual calls were:\n' + prettyPrintedCalls.join(',\n') + '.\n\n'; + return ( + 'But the actual calls were:\n' + + prettyPrintedCalls.join(',\n') + + '.\n\n' + ); } } return { pass: false, - message: 'Expected spy ' + actual.and.identity + ' to have been called only once, and with given args:\n' - + ' ' + util.pp(expectedArgs) + '\n' - + butString() + message: + 'Expected spy ' + + actual.and.identity + + ' to have been called only once, and with given args:\n' + + ' ' + + util.pp(expectedArgs) + + '\n' + + butString() }; } }; @@ -5910,8 +6212,10 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) { }; getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { - - var getErrorMsg = j$.formatErrorMsg('', 'expect().toHaveBeenCalledTimes()'); + var getErrorMsg = j$.formatErrorMsg( + '', + 'expect().toHaveBeenCalledTimes()' + ); /** * {@link expect} the actual (a {@link Spy}) to have been called the specified number of times. @@ -5926,23 +6230,43 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { return { compare: function(actual, expected) { if (!j$.isSpy(actual)) { - throw new Error(getErrorMsg('Expected a spy, but got ' + matchersUtil.pp(actual) + '.')); + throw new Error( + getErrorMsg( + 'Expected a spy, but got ' + matchersUtil.pp(actual) + '.' + ) + ); } var args = Array.prototype.slice.call(arguments, 0), result = { pass: false }; if (!j$.isNumber_(expected)) { - throw new Error(getErrorMsg('The expected times failed is a required argument and must be a number.')); + throw new Error( + getErrorMsg( + 'The expected times failed is a required argument and must be a number.' + ) + ); } actual = args[0]; var calls = actual.calls.count(); var timesMessage = expected === 1 ? 'once' : expected + ' times'; result.pass = calls === expected; - result.message = result.pass ? - 'Expected spy ' + actual.and.identity + ' not to have been called ' + timesMessage + '. It was called ' + calls + ' times.' : - 'Expected spy ' + actual.and.identity + ' to have been called ' + timesMessage + '. It was called ' + calls + ' times.'; + result.message = result.pass + ? 'Expected spy ' + + actual.and.identity + + ' not to have been called ' + + timesMessage + + '. It was called ' + + calls + + ' times.' + : 'Expected spy ' + + actual.and.identity + + ' to have been called ' + + timesMessage + + '. It was called ' + + calls + + ' times.'; return result; } }; @@ -5952,8 +6276,10 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { }; getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { - - var getErrorMsg = j$.formatErrorMsg('', 'expect().toHaveBeenCalledWith(...arguments)'); + var getErrorMsg = j$.formatErrorMsg( + '', + 'expect().toHaveBeenCalledWith(...arguments)' + ); /** * {@link expect} the actual (a {@link Spy}) to have been called with particular arguments at least once. @@ -5973,14 +6299,23 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { result = { pass: false }; if (!j$.isSpy(actual)) { - throw new Error(getErrorMsg('Expected a spy, but got ' + matchersUtil.pp(actual) + '.')); + throw new Error( + getErrorMsg( + 'Expected a spy, but got ' + matchersUtil.pp(actual) + '.' + ) + ); } if (!actual.calls.any()) { result.message = function() { - return 'Expected spy ' + actual.and.identity + ' to have been called with:\n' + - ' ' + matchersUtil.pp(expectedArgs) + - '\nbut it was never called.'; + return ( + 'Expected spy ' + + actual.and.identity + + ' to have been called with:\n' + + ' ' + + matchersUtil.pp(expectedArgs) + + '\nbut it was never called.' + ); }; return result; } @@ -5988,28 +6323,49 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { if (matchersUtil.contains(actual.calls.allArgs(), expectedArgs)) { result.pass = true; result.message = function() { - return 'Expected spy ' + actual.and.identity + ' not to have been called with:\n' + - ' ' + matchersUtil.pp(expectedArgs) + - '\nbut it was.'; + return ( + 'Expected spy ' + + actual.and.identity + + ' not to have been called with:\n' + + ' ' + + matchersUtil.pp(expectedArgs) + + '\nbut it was.' + ); }; } else { result.message = function() { - var prettyPrintedCalls = actual.calls.allArgs().map(function(argsForCall) { - return ' ' + matchersUtil.pp(argsForCall); - }); + var prettyPrintedCalls = actual.calls + .allArgs() + .map(function(argsForCall) { + return ' ' + matchersUtil.pp(argsForCall); + }); - var diffs = actual.calls.allArgs().map(function(argsForCall, callIx) { - var diffBuilder = new j$.DiffBuilder(); - matchersUtil.equals(argsForCall, expectedArgs, diffBuilder); - return 'Call ' + callIx + ':\n' + - diffBuilder.getMessage().replace(/^/mg, ' '); - }); + var diffs = actual.calls + .allArgs() + .map(function(argsForCall, callIx) { + var diffBuilder = new j$.DiffBuilder(); + matchersUtil.equals(argsForCall, expectedArgs, diffBuilder); + return ( + 'Call ' + + callIx + + ':\n' + + diffBuilder.getMessage().replace(/^/gm, ' ') + ); + }); - return 'Expected spy ' + actual.and.identity + ' to have been called with:\n' + - ' ' + matchersUtil.pp(expectedArgs) + '\n' + '' + + return ( + 'Expected spy ' + + actual.and.identity + + ' to have been called with:\n' + + ' ' + + matchersUtil.pp(expectedArgs) + + '\n' + + '' + 'but actual calls were:\n' + - prettyPrintedCalls.join(',\n') + '.\n\n' + - diffs.join('\n'); + prettyPrintedCalls.join(',\n') + + '.\n\n' + + diffs.join('\n') + ); }; } @@ -6048,9 +6404,9 @@ getJasmineRequireObj().toHaveClass = function(j$) { } function isElement(maybeEl) { - return maybeEl && - maybeEl.classList && - j$.isFunction_(maybeEl.classList.contains); + return ( + maybeEl && maybeEl.classList && j$.isFunction_(maybeEl.classList.contains) + ); } return toHaveClass; @@ -6071,10 +6427,14 @@ getJasmineRequireObj().toHaveSize = function(j$) { return { compare: function(actual, expected) { var result = { - pass: false - }; + pass: false + }; - if (j$.isA_('WeakSet', actual) || j$.isWeakMap(actual) || j$.isDataView(actual)) { + if ( + j$.isA_('WeakSet', actual) || + j$.isWeakMap(actual) || + j$.isDataView(actual) + ) { throw new Error('Cannot get size of ' + actual + '.'); } @@ -6091,17 +6451,24 @@ getJasmineRequireObj().toHaveSize = function(j$) { }; } - var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // eslint-disable-line compat/compat + var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // eslint-disable-line compat/compat function isLength(value) { - return (typeof value == 'number') && value > -1 && value % 1 === 0 && value <= MAX_SAFE_INTEGER; + return ( + typeof value == 'number' && + value > -1 && + value % 1 === 0 && + value <= MAX_SAFE_INTEGER + ); } return toHaveSize; }; getJasmineRequireObj().toMatch = function(j$) { - - var getErrorMsg = j$.formatErrorMsg('', 'expect().toMatch( || )'); + var getErrorMsg = j$.formatErrorMsg( + '', + 'expect().toMatch( || )' + ); /** * {@link expect} the actual value to match a regular expression @@ -6133,8 +6500,10 @@ getJasmineRequireObj().toMatch = function(j$) { }; getJasmineRequireObj().toThrow = function(j$) { - - var getErrorMsg = j$.formatErrorMsg('', 'expect(function() {}).toThrow()'); + var getErrorMsg = j$.formatErrorMsg( + '', + 'expect(function() {}).toThrow()' + ); /** * {@link expect} a function to `throw` something. @@ -6171,16 +6540,36 @@ getJasmineRequireObj().toThrow = function(j$) { if (arguments.length == 1) { result.pass = true; - result.message = function() { return 'Expected function not to throw, but it threw ' + matchersUtil.pp(thrown) + '.'; }; + result.message = function() { + return ( + 'Expected function not to throw, but it threw ' + + matchersUtil.pp(thrown) + + '.' + ); + }; return result; } if (matchersUtil.equals(thrown, expected)) { result.pass = true; - result.message = function() { return 'Expected function not to throw ' + matchersUtil.pp(expected) + '.'; }; + result.message = function() { + return ( + 'Expected function not to throw ' + + matchersUtil.pp(expected) + + '.' + ); + }; } else { - result.message = function() { return 'Expected function to throw ' + matchersUtil.pp(expected) + ', but it threw ' + matchersUtil.pp(thrown) + '.'; }; + result.message = function() { + return ( + 'Expected function to throw ' + + matchersUtil.pp(expected) + + ', but it threw ' + + matchersUtil.pp(thrown) + + '.' + ); + }; } return result; @@ -6192,8 +6581,10 @@ getJasmineRequireObj().toThrow = function(j$) { }; getJasmineRequireObj().toThrowError = function(j$) { - - var getErrorMsg = j$.formatErrorMsg('', 'expect(function() {}).toThrowError(, )'); + var getErrorMsg = j$.formatErrorMsg( + '', + 'expect(function() {}).toThrowError(, )' + ); /** * {@link expect} a function to `throw` an `Error`. @@ -6227,7 +6618,13 @@ getJasmineRequireObj().toThrowError = function(j$) { } if (!j$.isError_(thrown)) { - return fail(function() { return 'Expected function to throw an Error, but it threw ' + matchersUtil.pp(thrown) + '.'; }); + return fail(function() { + return ( + 'Expected function to throw an Error, but it threw ' + + matchersUtil.pp(thrown) + + '.' + ); + }); } return errorMatcher.match(thrown); @@ -6261,7 +6658,11 @@ getJasmineRequireObj().toThrowError = function(j$) { function anyMatcher() { return { match: function(error) { - return pass('Expected function not to throw an Error, but it threw ' + j$.fnNameFor(error) + '.'); + return pass( + 'Expected function not to throw an Error, but it threw ' + + j$.fnNameFor(error) + + '.' + ); } }; } @@ -6269,9 +6670,13 @@ getJasmineRequireObj().toThrowError = function(j$) { function exactMatcher(expected, errorType) { if (expected && !isStringOrRegExp(expected)) { if (errorType) { - throw new Error(getErrorMsg('Expected error message is not a string or RegExp.')); + throw new Error( + getErrorMsg('Expected error message is not a string or RegExp.') + ); } else { - throw new Error(getErrorMsg('Expected is not an Error, string, or RegExp.')); + throw new Error( + getErrorMsg('Expected is not an Error, string, or RegExp.') + ); } } @@ -6283,11 +6688,15 @@ getJasmineRequireObj().toThrowError = function(j$) { } } - var errorTypeDescription = errorType ? j$.fnNameFor(errorType) : 'an exception'; + var errorTypeDescription = errorType + ? j$.fnNameFor(errorType) + : 'an exception'; function thrownDescription(thrown) { - var thrownName = errorType ? j$.fnNameFor(thrown.constructor) : 'an exception', - thrownMessage = ''; + var thrownName = errorType + ? j$.fnNameFor(thrown.constructor) + : 'an exception', + thrownMessage = ''; if (expected) { thrownMessage = ' with message ' + matchersUtil.pp(thrown.message); @@ -6307,20 +6716,33 @@ getJasmineRequireObj().toThrowError = function(j$) { } function matches(error) { - return (errorType === null || error instanceof errorType) && - (expected === null || messageMatch(error.message)); + return ( + (errorType === null || error instanceof errorType) && + (expected === null || messageMatch(error.message)) + ); } return { match: function(thrown) { if (matches(thrown)) { return pass(function() { - return 'Expected function not to throw ' + errorTypeDescription + messageDescription() + '.'; + return ( + 'Expected function not to throw ' + + errorTypeDescription + + messageDescription() + + '.' + ); }); } else { return fail(function() { - return 'Expected function to throw ' + errorTypeDescription + messageDescription() + - ', but it threw ' + thrownDescription(thrown) + '.'; + return ( + 'Expected function to throw ' + + errorTypeDescription + + messageDescription() + + ', but it threw ' + + thrownDescription(thrown) + + '.' + ); }); } } @@ -6328,7 +6750,7 @@ getJasmineRequireObj().toThrowError = function(j$) { } function isStringOrRegExp(potential) { - return potential instanceof RegExp || (typeof potential == 'string'); + return potential instanceof RegExp || typeof potential == 'string'; } function isAnErrorType(type) { @@ -6360,7 +6782,10 @@ getJasmineRequireObj().toThrowError = function(j$) { }; getJasmineRequireObj().toThrowMatching = function(j$) { - var usageError = j$.formatErrorMsg('', 'expect(function() {}).toThrowMatching()'); + var usageError = j$.formatErrorMsg( + '', + 'expect(function() {}).toThrowMatching()' + ); /** * {@link expect} a function to `throw` something matching a predicate. @@ -6392,20 +6817,29 @@ getJasmineRequireObj().toThrowMatching = function(j$) { } if (predicate(thrown)) { - return pass('Expected function not to throw an exception matching a predicate.'); + return pass( + 'Expected function not to throw an exception matching a predicate.' + ); } else { - return fail(function() { - return 'Expected function to throw an exception matching a predicate, ' + - 'but it threw ' + thrownDescription(thrown) + '.'; - }); + return fail(function() { + return ( + 'Expected function to throw an exception matching a predicate, ' + + 'but it threw ' + + thrownDescription(thrown) + + '.' + ); + }); } } }; function thrownDescription(thrown) { if (thrown && thrown.constructor) { - return j$.fnNameFor(thrown.constructor) + ' with message ' + - matchersUtil.pp(thrown.message); + return ( + j$.fnNameFor(thrown.constructor) + + ' with message ' + + matchersUtil.pp(thrown.message) + ); } else { return matchersUtil.pp(thrown); }