Ran Prettier
diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js
index dd1b255..32b1d92 100644
--- a/lib/jasmine-core/jasmine.js
+++ b/lib/jasmine-core/jasmine.js
@@ -2350,12 +2350,11 @@
};
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;
@@ -2400,7 +2399,6 @@
};
getJasmineRequireObj().Anything = function(j$) {
-
function Anything() {}
Anything.prototype.asymmetricMatch = function(other) {
@@ -2421,7 +2419,11 @@
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
@@ -2441,22 +2443,28 @@
return true;
};
- ArrayContaining.prototype.jasmineToString = function (pp) {
- return '<jasmine.arrayContaining(' + pp(this.sample) +')>';
+ ArrayContaining.prototype.jasmineToString = function(pp) {
+ return '<jasmine.arrayContaining(' + pp(this.sample) + ')>';
};
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) {
@@ -2480,11 +2488,10 @@
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;
}
@@ -2499,7 +2506,7 @@
return false;
};
- Empty.prototype.jasmineToString = function () {
+ Empty.prototype.jasmineToString = function() {
return '<jasmine.empty>';
};
@@ -2507,7 +2514,6 @@
};
getJasmineRequireObj().Falsy = function(j$) {
-
function Falsy() {}
Falsy.prototype.asymmetricMatch = function(other) {
@@ -2524,7 +2530,9 @@
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;
@@ -2540,8 +2548,8 @@
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();
@@ -2563,11 +2571,10 @@
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;
}
@@ -2583,7 +2590,7 @@
return false;
};
- NotEmpty.prototype.jasmineToString = function () {
+ NotEmpty.prototype.jasmineToString = function() {
return '<jasmine.notEmpty>';
};
@@ -2591,7 +2598,6 @@
};
getJasmineRequireObj().ObjectContaining = function(j$) {
-
function ObjectContaining(sample) {
this.sample = sample;
}
@@ -2609,7 +2615,7 @@
}
function hasProperty(obj, property) {
- if (!obj || typeof(obj) !== 'object') {
+ if (!obj || typeof obj !== 'object') {
return false;
}
@@ -2621,12 +2627,22 @@
}
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;
}
}
@@ -2643,7 +2659,7 @@
}
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];
@@ -2665,7 +2681,9 @@
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;
@@ -2703,7 +2721,6 @@
};
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');
@@ -2724,7 +2741,6 @@
};
getJasmineRequireObj().Truthy = function(j$) {
-
function Truthy() {}
Truthy.prototype.asymmetricMatch = function(other) {
@@ -4133,8 +4149,12 @@
}
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 };
+ }
);
}
};
@@ -4160,8 +4180,12 @@
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 };
+ }
);
}
};
@@ -4185,35 +4209,44 @@
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) +
+ '.'
+ };
+ }
}
- }
);
}
};
@@ -4240,7 +4273,9 @@
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);
@@ -4252,7 +4287,9 @@
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);
+ }
);
}
};
@@ -4264,16 +4301,25 @@
}
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);
}
@@ -4283,18 +4329,25 @@
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;
@@ -4309,12 +4362,17 @@
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))
+ );
}
};
@@ -4338,8 +4396,12 @@
}
return actual.then(
- function() { return {pass: true}; },
- function() { return {pass: false}; }
+ function() {
+ return { pass: true };
+ },
+ function() {
+ return { pass: false };
+ }
);
}
};
@@ -4367,9 +4429,12 @@
}
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(
@@ -4382,7 +4447,11 @@
} 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) +
+ '.'
};
}
},
@@ -4398,7 +4467,7 @@
};
};
-getJasmineRequireObj().DiffBuilder = function (j$) {
+getJasmineRequireObj().DiffBuilder = function(j$) {
return function DiffBuilder(config) {
var prettyPrinter = (config || {}).prettyPrinter || j$.makePrettyPrinter(),
mismatches = new j$.MismatchTree(),
@@ -4407,21 +4476,28 @@
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;
@@ -4432,15 +4508,22 @@
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;
@@ -4449,7 +4532,7 @@
return messages.join('\n');
},
- withPath: function (pathComponent, block) {
+ withPath: function(pathComponent, block) {
var oldPath = path;
path = path.add(pathComponent);
block();
@@ -4458,22 +4541,32 @@
};
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;
@@ -4489,9 +4582,8 @@
handleAsymmetricExpected();
}
- return {actual: actual, expected: expected};
+ return { actual: actual, expected: expected };
}
-
};
getJasmineRequireObj().MatchersUtil = function(j$) {
@@ -4517,7 +4609,7 @@
* @return {string} The pretty-printed value
*/
this.pp = options.pp || function() {};
- };
+ }
/**
* Determines whether `haystack` contains `needle`, using the same comparison
@@ -4535,9 +4627,10 @@
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;
@@ -4556,9 +4649,12 @@
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;
@@ -4575,20 +4671,41 @@
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;
@@ -4623,7 +4740,12 @@
* @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)) {
@@ -4642,10 +4764,26 @@
// 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;
}
@@ -4703,7 +4841,8 @@
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();
}
@@ -4720,10 +4859,12 @@
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();
@@ -4757,7 +4898,9 @@
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);
@@ -4779,10 +4922,20 @@
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;
}
});
}
@@ -4797,11 +4950,11 @@
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.
@@ -4822,13 +4975,30 @@
// 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()
+ );
}
}
@@ -4843,12 +5013,12 @@
}
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
@@ -4872,7 +5042,14 @@
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);
@@ -4887,27 +5064,35 @@
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;
}
@@ -4915,13 +5100,17 @@
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;
}
});
@@ -4939,23 +5128,24 @@
};
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 = [];
@@ -4974,21 +5164,25 @@
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');
@@ -4999,17 +5193,25 @@
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) {
@@ -5027,8 +5229,7 @@
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
@@ -5043,7 +5244,7 @@
this.isMismatch = false;
}
- MismatchTree.prototype.add = function (path, formatter) {
+ MismatchTree.prototype.add = function(path, formatter) {
var key, child;
if (path.depth() === 0) {
@@ -5063,8 +5264,9 @@
}
};
- 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)) {
@@ -5089,7 +5291,6 @@
return MismatchTree;
};
-
getJasmineRequireObj().nothing = function() {
/**
* {@link expect} nothing explicitly.
@@ -5158,7 +5359,7 @@
return '.' + prop;
}
- return '[\'' + prop + '\']';
+ return "['" + prop + "']";
}
function map(array, fn) {
@@ -5206,7 +5407,8 @@
* 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) {
@@ -5215,7 +5417,13 @@
};
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;
@@ -5245,8 +5453,13 @@
}
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 +
+ ').'
);
}
@@ -5277,7 +5490,7 @@
return {
compare: function(actual) {
return {
- pass: (void 0 !== actual)
+ pass: void 0 !== actual
};
}
};
@@ -5353,7 +5566,6 @@
return toBeGreaterThan;
};
-
getJasmineRequireObj().toBeGreaterThanOrEqual = function() {
/**
* {@link expect} the actual value to be greater than or equal to the expected value.
@@ -5378,7 +5590,10 @@
};
getJasmineRequireObj().toBeInstanceOf = function(j$) {
- var usageError = j$.formatErrorMsg('<toBeInstanceOf>', 'expect(value).toBeInstanceOf(<ConstructorFunction>)');
+ var usageError = j$.formatErrorMsg(
+ '<toBeInstanceOf>',
+ 'expect(value).toBeInstanceOf(<ConstructorFunction>)'
+ );
/**
* {@link expect} the actual to be an instance of the expected class
@@ -5394,27 +5609,42 @@
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
};
}
}
@@ -5436,7 +5666,6 @@
*/
function toBeLessThan() {
return {
-
compare: function(actual, expected) {
return {
pass: actual < expected
@@ -5460,7 +5689,6 @@
*/
function toBeLessThanOrEqual() {
return {
-
compare: function(actual, expected) {
return {
pass: actual <= expected
@@ -5485,13 +5713,15 @@
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;
@@ -5515,13 +5745,15 @@
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;
@@ -5567,13 +5799,15 @@
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;
@@ -5664,7 +5898,6 @@
function toContain(matchersUtil) {
return {
compare: function(actual, expected) {
-
return {
pass: matchersUtil.contains(actual, expected)
};
@@ -5691,7 +5924,7 @@
var result = {
pass: false
},
- diffBuilder = j$.DiffBuilder({prettyPrinter: matchersUtil.pp});
+ diffBuilder = j$.DiffBuilder({ prettyPrinter: matchersUtil.pp });
result.pass = matchersUtil.equals(actual, expected, diffBuilder);
@@ -5707,8 +5940,10 @@
};
getJasmineRequireObj().toHaveBeenCalled = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalled>', 'expect(<spyObj>).toHaveBeenCalled()');
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toHaveBeenCalled>',
+ 'expect(<spyObj>).toHaveBeenCalled()'
+ );
/**
* {@link expect} the actual (a {@link Spy}) to have been called.
@@ -5725,18 +5960,24 @@
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;
}
@@ -5747,8 +5988,10 @@
};
getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalledBefore>', 'expect(<spyObj>).toHaveBeenCalledBefore(<spyObj>)');
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toHaveBeenCalledBefore>',
+ 'expect(<spyObj>).toHaveBeenCalledBefore(<spyObj>)'
+ );
/**
* {@link expect} the actual value (a {@link Spy}) to have been called before another {@link Spy}.
@@ -5763,20 +6006,30 @@
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;
}
@@ -5786,17 +6039,36 @@
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;
}
}
@@ -5808,9 +6080,11 @@
return toHaveBeenCalledBefore;
};
-getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) {
-
- var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalledOnceWith>', 'expect(<spyObj>).toHaveBeenCalledOnceWith(...arguments)');
+getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) {
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toHaveBeenCalledOnceWith>',
+ 'expect(<spyObj>).toHaveBeenCalledOnceWith(...arguments)'
+ );
/**
* {@link expect} the actual (a {@link Spy}) to have been called exactly once, and exactly with the particular arguments.
@@ -5823,31 +6097,44 @@
*/
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 ' + j$.pp(actual) + '.'));
+ throw new Error(
+ getErrorMsg('Expected a spy, but got ' + j$.pp(actual) + '.')
+ );
}
- var prettyPrintedCalls = actual.calls.allArgs().map(function (argsForCall) {
- return ' ' + j$.pp(argsForCall);
- });
+ var prettyPrintedCalls = actual.calls
+ .allArgs()
+ .map(function(argsForCall) {
+ return ' ' + j$.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'
- + ' ' + j$.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' +
+ ' ' +
+ j$.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();
@@ -5859,17 +6146,32 @@
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'
- + ' ' + j$.pp(expectedArgs) + '\n'
- + butString()
+ message:
+ 'Expected spy ' +
+ actual.and.identity +
+ ' to have been called only once, and with given args:\n' +
+ ' ' +
+ j$.pp(expectedArgs) +
+ '\n' +
+ butString()
};
}
};
@@ -5879,8 +6181,10 @@
};
getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalledTimes>', 'expect(<spyObj>).toHaveBeenCalledTimes(<Number>)');
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toHaveBeenCalledTimes>',
+ 'expect(<spyObj>).toHaveBeenCalledTimes(<Number>)'
+ );
/**
* {@link expect} the actual (a {@link Spy}) to have been called the specified number of times.
@@ -5895,23 +6199,43 @@
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;
}
};
@@ -5921,8 +6245,10 @@
};
getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalledWith>', 'expect(<spyObj>).toHaveBeenCalledWith(...arguments)');
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toHaveBeenCalledWith>',
+ 'expect(<spyObj>).toHaveBeenCalledWith(...arguments)'
+ );
/**
* {@link expect} the actual (a {@link Spy}) to have been called with particular arguments at least once.
@@ -5942,14 +6268,23 @@
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;
}
@@ -5957,28 +6292,49 @@
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')
+ );
};
}
@@ -6017,9 +6373,9 @@
}
function isElement(maybeEl) {
- return maybeEl &&
- maybeEl.classList &&
- j$.isFunction_(maybeEl.classList.contains);
+ return (
+ maybeEl && maybeEl.classList && j$.isFunction_(maybeEl.classList.contains)
+ );
}
return toHaveClass;
@@ -6040,10 +6396,14 @@
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 + '.');
}
@@ -6060,17 +6420,24 @@
};
}
- 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('<toMatch>', 'expect(<expectation>).toMatch(<string> || <regexp>)');
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toMatch>',
+ 'expect(<expectation>).toMatch(<string> || <regexp>)'
+ );
/**
* {@link expect} the actual value to match a regular expression
@@ -6102,8 +6469,10 @@
};
getJasmineRequireObj().toThrow = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('<toThrow>', 'expect(function() {<expectation>}).toThrow()');
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toThrow>',
+ 'expect(function() {<expectation>}).toThrow()'
+ );
/**
* {@link expect} a function to `throw` something.
@@ -6140,16 +6509,36 @@
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;
@@ -6161,8 +6550,10 @@
};
getJasmineRequireObj().toThrowError = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('<toThrowError>', 'expect(function() {<expectation>}).toThrowError(<ErrorConstructor>, <message>)');
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toThrowError>',
+ 'expect(function() {<expectation>}).toThrowError(<ErrorConstructor>, <message>)'
+ );
/**
* {@link expect} a function to `throw` an `Error`.
@@ -6196,7 +6587,13 @@
}
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);
@@ -6230,7 +6627,11 @@
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) +
+ '.'
+ );
}
};
}
@@ -6238,9 +6639,13 @@
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.')
+ );
}
}
@@ -6252,11 +6657,15 @@
}
}
- 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);
@@ -6276,20 +6685,33 @@
}
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) +
+ '.'
+ );
});
}
}
@@ -6297,7 +6719,7 @@
}
function isStringOrRegExp(potential) {
- return potential instanceof RegExp || (typeof potential == 'string');
+ return potential instanceof RegExp || typeof potential == 'string';
}
function isAnErrorType(type) {
@@ -6329,7 +6751,10 @@
};
getJasmineRequireObj().toThrowMatching = function(j$) {
- var usageError = j$.formatErrorMsg('<toThrowMatching>', 'expect(function() {<expectation>}).toThrowMatching(<Predicate>)');
+ var usageError = j$.formatErrorMsg(
+ '<toThrowMatching>',
+ 'expect(function() {<expectation>}).toThrowMatching(<Predicate>)'
+ );
/**
* {@link expect} a function to `throw` something matching a predicate.
@@ -6361,20 +6786,29 @@
}
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);
}
diff --git a/spec/.eslintrc.js b/spec/.eslintrc.js
index bfbec21..4d02d33 100644
--- a/spec/.eslintrc.js
+++ b/spec/.eslintrc.js
@@ -1,17 +1,14 @@
module.exports = {
- "ignorePatterns": [
- "support/ci.js",
- "support/jasmine-browser.js"
- ],
+ ignorePatterns: ['support/ci.js', 'support/jasmine-browser.js'],
rules: {
// Relax rules for now to allow for the quirks of the test suite
// TODO: We should probably remove these & fix the resulting errors
- "quotes": "off",
- "semi": "off",
- "key-spacing": "off",
- "space-before-blocks": "off",
- "no-unused-vars": "off",
- "no-trailing-spaces": "off",
- "block-spacing": "off",
+ quotes: 'off',
+ semi: 'off',
+ 'key-spacing': 'off',
+ 'space-before-blocks': 'off',
+ 'no-unused-vars': 'off',
+ 'no-trailing-spaces': 'off',
+ 'block-spacing': 'off'
}
-}
+};
diff --git a/spec/core/asymmetric_equality/AnySpec.js b/spec/core/asymmetric_equality/AnySpec.js
index 8e28c30..0903cf8 100644
--- a/spec/core/asymmetric_equality/AnySpec.js
+++ b/spec/core/asymmetric_equality/AnySpec.js
@@ -1,35 +1,35 @@
-describe("Any", function() {
- it("matches a string", function() {
+describe('Any', function() {
+ it('matches a string', function() {
var any = new jasmineUnderTest.Any(String);
- expect(any.asymmetricMatch("foo")).toBe(true);
+ expect(any.asymmetricMatch('foo')).toBe(true);
});
- it("matches a number", function() {
+ it('matches a number', function() {
var any = new jasmineUnderTest.Any(Number);
expect(any.asymmetricMatch(1)).toBe(true);
});
- it("matches a function", function() {
+ it('matches a function', function() {
var any = new jasmineUnderTest.Any(Function);
- expect(any.asymmetricMatch(function(){})).toBe(true);
+ expect(any.asymmetricMatch(function() {})).toBe(true);
});
- it("matches an Object", function() {
+ it('matches an Object', function() {
var any = new jasmineUnderTest.Any(Object);
expect(any.asymmetricMatch({})).toBe(true);
});
- it("matches a Boolean", function() {
+ it('matches a Boolean', function() {
var any = new jasmineUnderTest.Any(Boolean);
expect(any.asymmetricMatch(true)).toBe(true);
});
- it("matches a Map", function() {
+ it('matches a Map', function() {
jasmine.getEnv().requireFunctioningMaps();
var any = new jasmineUnderTest.Any(Map);
@@ -37,7 +37,7 @@
expect(any.asymmetricMatch(new Map())).toBe(true); // eslint-disable-line compat/compat
});
- it("matches a Set", function() {
+ it('matches a Set', function() {
jasmine.getEnv().requireFunctioningSets();
var any = new jasmineUnderTest.Any(Set);
@@ -45,7 +45,7 @@
expect(any.asymmetricMatch(new Set())).toBe(true); // eslint-disable-line compat/compat
});
- it("matches a TypedArray", function() {
+ it('matches a TypedArray', function() {
jasmine.getEnv().requireFunctioningTypedArrays();
var any = new jasmineUnderTest.Any(Uint32Array); // eslint-disable-line compat/compat
@@ -53,7 +53,7 @@
expect(any.asymmetricMatch(new Uint32Array([]))).toBe(true); // eslint-disable-line compat/compat
});
- it("matches a Symbol", function() {
+ it('matches a Symbol', function() {
jasmine.getEnv().requireFunctioningSymbols();
var any = new jasmineUnderTest.Any(Symbol); // eslint-disable-line compat/compat
@@ -61,14 +61,14 @@
expect(any.asymmetricMatch(Symbol())).toBe(true); // eslint-disable-line compat/compat
});
- it("matches another constructed object", function() {
+ it('matches another constructed object', function() {
var Thing = function() {},
any = new jasmineUnderTest.Any(Thing);
expect(any.asymmetricMatch(new Thing())).toBe(true);
});
- it("does not treat null as an Object", function() {
+ it('does not treat null as an Object', function() {
var any = new jasmineUnderTest.Any(Object);
expect(any.asymmetricMatch(null)).toBe(false);
@@ -81,8 +81,8 @@
expect(any.jasmineToString()).toEqual('<jasmine.any(Number)>');
});
- describe("when called without an argument", function() {
- it("tells the user to pass a constructor or use jasmine.anything()", function() {
+ describe('when called without an argument', function() {
+ it('tells the user to pass a constructor or use jasmine.anything()', function() {
expect(function() {
new jasmineUnderTest.Any();
}).toThrowError(TypeError, /constructor.*anything/);
diff --git a/spec/core/asymmetric_equality/AnythingSpec.js b/spec/core/asymmetric_equality/AnythingSpec.js
index 4e251b9..61ac14e 100644
--- a/spec/core/asymmetric_equality/AnythingSpec.js
+++ b/spec/core/asymmetric_equality/AnythingSpec.js
@@ -1,29 +1,29 @@
-describe("Anything", function() {
- it("matches a string", function() {
+describe('Anything', function() {
+ it('matches a string', function() {
var anything = new jasmineUnderTest.Anything();
expect(anything.asymmetricMatch('foo')).toBe(true);
});
- it("matches a number", function() {
+ it('matches a number', function() {
var anything = new jasmineUnderTest.Anything();
expect(anything.asymmetricMatch(42)).toBe(true);
});
- it("matches an object", function() {
+ it('matches an object', function() {
var anything = new jasmineUnderTest.Anything();
expect(anything.asymmetricMatch({ foo: 'bar' })).toBe(true);
});
- it("matches an array", function() {
+ it('matches an array', function() {
var anything = new jasmineUnderTest.Anything();
- expect(anything.asymmetricMatch([1,2,3])).toBe(true);
+ expect(anything.asymmetricMatch([1, 2, 3])).toBe(true);
});
- it("matches a Map", function() {
+ it('matches a Map', function() {
jasmine.getEnv().requireFunctioningMaps();
var anything = new jasmineUnderTest.Anything();
@@ -31,7 +31,7 @@
expect(anything.asymmetricMatch(new Map())).toBe(true); // eslint-disable-line compat/compat
});
- it("matches a Set", function() {
+ it('matches a Set', function() {
jasmine.getEnv().requireFunctioningSets();
var anything = new jasmineUnderTest.Anything();
@@ -39,7 +39,7 @@
expect(anything.asymmetricMatch(new Set())).toBe(true); // eslint-disable-line compat/compat
});
- it("matches a TypedArray", function() {
+ it('matches a TypedArray', function() {
jasmine.getEnv().requireFunctioningTypedArrays();
var anything = new jasmineUnderTest.Anything();
@@ -47,7 +47,7 @@
expect(anything.asymmetricMatch(new Uint32Array([]))).toBe(true); // eslint-disable-line compat/compat
});
- it("matches a Symbol", function() {
+ it('matches a Symbol', function() {
jasmine.getEnv().requireFunctioningSymbols();
var anything = new jasmineUnderTest.Anything();
@@ -71,6 +71,6 @@
it("jasmineToString's itself", function() {
var anything = new jasmineUnderTest.Anything();
- expect(anything.jasmineToString()).toEqual("<jasmine.anything>");
+ expect(anything.jasmineToString()).toEqual('<jasmine.anything>');
});
});
diff --git a/spec/core/asymmetric_equality/ArrayContainingSpec.js b/spec/core/asymmetric_equality/ArrayContainingSpec.js
index 33e411e..71d44df 100644
--- a/spec/core/asymmetric_equality/ArrayContainingSpec.js
+++ b/spec/core/asymmetric_equality/ArrayContainingSpec.js
@@ -1,47 +1,47 @@
-describe("ArrayContaining", function() {
- it("matches any actual to an empty array", function() {
+describe('ArrayContaining', function() {
+ it('matches any actual to an empty array', function() {
var containing = new jasmineUnderTest.ArrayContaining([]);
- expect(containing.asymmetricMatch("foo")).toBe(true);
+ expect(containing.asymmetricMatch('foo')).toBe(true);
});
- it("does not work when not passed an array", function() {
- var containing = new jasmineUnderTest.ArrayContaining("foo");
+ it('does not work when not passed an array', function() {
+ var containing = new jasmineUnderTest.ArrayContaining('foo');
expect(function() {
containing.asymmetricMatch([]);
}).toThrowError(/not 'foo'/);
});
- it("matches when the item is in the actual", function() {
- var containing = new jasmineUnderTest.ArrayContaining(["foo"]);
+ it('matches when the item is in the actual', function() {
+ var containing = new jasmineUnderTest.ArrayContaining(['foo']);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(containing.asymmetricMatch(["foo"], matchersUtil)).toBe(true);
+ expect(containing.asymmetricMatch(['foo'], matchersUtil)).toBe(true);
});
- it("matches when additional items are in the actual", function() {
- var containing = new jasmineUnderTest.ArrayContaining(["foo"]);
+ it('matches when additional items are in the actual', function() {
+ var containing = new jasmineUnderTest.ArrayContaining(['foo']);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(containing.asymmetricMatch(["foo", "bar"], matchersUtil)).toBe(true);
+ expect(containing.asymmetricMatch(['foo', 'bar'], matchersUtil)).toBe(true);
});
- it("does not match when the item is not in the actual", function() {
- var containing = new jasmineUnderTest.ArrayContaining(["foo"]);
+ it('does not match when the item is not in the actual', function() {
+ var containing = new jasmineUnderTest.ArrayContaining(['foo']);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(containing.asymmetricMatch(["bar"], matchersUtil)).toBe(false);
+ expect(containing.asymmetricMatch(['bar'], matchersUtil)).toBe(false);
});
- it("does not match when the actual is not an array", function() {
- var containing = new jasmineUnderTest.ArrayContaining(["foo"]);
+ it('does not match when the actual is not an array', function() {
+ var containing = new jasmineUnderTest.ArrayContaining(['foo']);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(containing.asymmetricMatch("foo", matchersUtil)).toBe(false);
+ expect(containing.asymmetricMatch('foo', matchersUtil)).toBe(false);
});
- it("jasmineToStrings itself", function() {
+ it('jasmineToStrings itself', function() {
var sample = [],
matcher = new jasmineUnderTest.ArrayContaining(sample),
pp = jasmine.createSpy('pp').and.returnValue('sample');
@@ -52,17 +52,23 @@
expect(pp).toHaveBeenCalledWith(sample);
});
- it("uses custom equality testers", function() {
+ it('uses custom equality testers', function() {
var tester = function(a, b) {
// All "foo*" strings match each other.
- if (typeof a == "string" && typeof b == "string" &&
- a.substr(0, 3) == "foo" && b.substr(0, 3) == "foo") {
+ if (
+ typeof a == 'string' &&
+ typeof b == 'string' &&
+ a.substr(0, 3) == 'foo' &&
+ b.substr(0, 3) == 'foo'
+ ) {
return true;
}
};
- var containing = new jasmineUnderTest.ArrayContaining(["fooVal"]);
- var matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [tester]});
+ var containing = new jasmineUnderTest.ArrayContaining(['fooVal']);
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: [tester]
+ });
- expect(containing.asymmetricMatch(["fooBar"], matchersUtil)).toBe(true);
+ expect(containing.asymmetricMatch(['fooBar'], matchersUtil)).toBe(true);
});
});
diff --git a/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js b/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js
index fd0bb30..c25470a 100644
--- a/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js
+++ b/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js
@@ -1,35 +1,37 @@
-describe("ArrayWithExactContents", function() {
- it("matches an array with the same items in a different order", function() {
+describe('ArrayWithExactContents', function() {
+ it('matches an array with the same items in a different order', function() {
var matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matcher.asymmetricMatch([2, 'a', /a/], matchersUtil)).toBe(true);
});
- it("does not work when not passed an array", function() {
- var matcher = new jasmineUnderTest.ArrayWithExactContents("foo");
+ it('does not work when not passed an array', function() {
+ var matcher = new jasmineUnderTest.ArrayWithExactContents('foo');
expect(function() {
matcher.asymmetricMatch([]);
}).toThrowError(/not 'foo'/);
});
- it("does not match when an item is missing", function() {
+ it('does not match when an item is missing', function() {
var matcher = new jasmineUnderTest.ArrayWithExactContents(['a', 2, /a/]);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matcher.asymmetricMatch(['a', 2], matchersUtil)).toBe(false);
- expect(matcher.asymmetricMatch(['a', 2, undefined], matchersUtil)).toBe(false);
+ expect(matcher.asymmetricMatch(['a', 2, undefined], matchersUtil)).toBe(
+ false
+ );
});
- it("does not match when there is an extra item", function() {
+ it('does not match when there is an extra item', function() {
var matcher = new jasmineUnderTest.ArrayWithExactContents(['a']);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matcher.asymmetricMatch(['a', 2], matchersUtil)).toBe(false);
});
- it("jasmineToStrings itself", function() {
+ it('jasmineToStrings itself', function() {
var sample = [],
matcher = new jasmineUnderTest.ArrayWithExactContents(sample),
pp = jasmine.createSpy('pp').and.returnValue('sample');
@@ -40,17 +42,23 @@
expect(pp).toHaveBeenCalledWith(sample);
});
- it("uses custom equality testers", function() {
+ it('uses custom equality testers', function() {
var tester = function(a, b) {
// All "foo*" strings match each other.
- if (typeof a == "string" && typeof b == "string" &&
- a.substr(0, 3) == "foo" && b.substr(0, 3) == "foo") {
+ if (
+ typeof a == 'string' &&
+ typeof b == 'string' &&
+ a.substr(0, 3) == 'foo' &&
+ b.substr(0, 3) == 'foo'
+ ) {
return true;
}
};
- var matcher = new jasmineUnderTest.ArrayWithExactContents(["fooVal"]);
- var matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [tester]});
+ var matcher = new jasmineUnderTest.ArrayWithExactContents(['fooVal']);
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: [tester]
+ });
- expect(matcher.asymmetricMatch(["fooBar"], matchersUtil)).toBe(true);
+ expect(matcher.asymmetricMatch(['fooBar'], matchersUtil)).toBe(true);
});
});
diff --git a/spec/core/asymmetric_equality/EmptySpec.js b/spec/core/asymmetric_equality/EmptySpec.js
index 48271ce..4ef48a8 100644
--- a/spec/core/asymmetric_equality/EmptySpec.js
+++ b/spec/core/asymmetric_equality/EmptySpec.js
@@ -1,27 +1,27 @@
-describe("Empty", function () {
- it("matches an empty object", function () {
+describe('Empty', function() {
+ it('matches an empty object', function() {
var empty = new jasmineUnderTest.Empty();
expect(empty.asymmetricMatch({})).toBe(true);
- expect(empty.asymmetricMatch({undefined: false})).toBe(false);
+ expect(empty.asymmetricMatch({ undefined: false })).toBe(false);
});
- it("matches an empty array", function () {
+ it('matches an empty array', function() {
var empty = new jasmineUnderTest.Empty();
expect(empty.asymmetricMatch([])).toBe(true);
expect(empty.asymmetricMatch([1, 12, 3])).toBe(false);
});
- it("matches an empty string", function () {
+ it('matches an empty string', function() {
var empty = new jasmineUnderTest.Empty();
- expect(empty.asymmetricMatch("")).toBe(true);
+ expect(empty.asymmetricMatch('')).toBe(true);
expect(empty.asymmetricMatch('')).toBe(true);
expect(empty.asymmetricMatch('12312')).toBe(false);
});
- it("matches an empty map", function () {
+ it('matches an empty map', function() {
jasmine.getEnv().requireFunctioningMaps();
var empty = new jasmineUnderTest.Empty();
var fullMap = new Map(); // eslint-disable-line compat/compat
@@ -31,7 +31,7 @@
expect(empty.asymmetricMatch(fullMap)).toBe(false);
});
- it("matches an empty set", function () {
+ it('matches an empty set', function() {
jasmine.getEnv().requireFunctioningSets();
var empty = new jasmineUnderTest.Empty();
var fullSet = new Set(); // eslint-disable-line compat/compat
@@ -41,11 +41,11 @@
expect(empty.asymmetricMatch(fullSet)).toBe(false);
});
- it("matches an empty typed array", function() {
+ it('matches an empty typed array', function() {
jasmine.getEnv().requireFunctioningTypedArrays();
var empty = new jasmineUnderTest.Empty();
expect(empty.asymmetricMatch(new Int16Array())).toBe(true); // eslint-disable-line compat/compat
- expect(empty.asymmetricMatch(new Int16Array([1,2]))).toBe(false); // eslint-disable-line compat/compat
+ expect(empty.asymmetricMatch(new Int16Array([1, 2]))).toBe(false); // eslint-disable-line compat/compat
});
});
diff --git a/spec/core/asymmetric_equality/FalsySpec.js b/spec/core/asymmetric_equality/FalsySpec.js
index 581bedc..f511c14 100644
--- a/spec/core/asymmetric_equality/FalsySpec.js
+++ b/spec/core/asymmetric_equality/FalsySpec.js
@@ -1,38 +1,38 @@
-describe("Falsy", function() {
- it("is true for an empty string", function() {
- var falsy = new jasmineUnderTest.Falsy();
+describe('Falsy', function() {
+ it('is true for an empty string', function() {
+ var falsy = new jasmineUnderTest.Falsy();
- expect(falsy.asymmetricMatch("")).toBe(true);
- expect(falsy.asymmetricMatch('')).toBe(true);
- expect(falsy.asymmetricMatch('asdasdad')).toBe(false);
- });
+ expect(falsy.asymmetricMatch('')).toBe(true);
+ expect(falsy.asymmetricMatch('')).toBe(true);
+ expect(falsy.asymmetricMatch('asdasdad')).toBe(false);
+ });
- it("is false for a number that is 0", function() {
- var falsy = new jasmineUnderTest.Falsy(Number);
+ it('is false for a number that is 0', function() {
+ var falsy = new jasmineUnderTest.Falsy(Number);
- expect(falsy.asymmetricMatch(1)).toBe(false);
- expect(falsy.asymmetricMatch(0)).toBe(true);
- expect(falsy.asymmetricMatch(-23)).toBe(false);
- expect(falsy.asymmetricMatch(-3.1)).toBe(false);
- });
+ expect(falsy.asymmetricMatch(1)).toBe(false);
+ expect(falsy.asymmetricMatch(0)).toBe(true);
+ expect(falsy.asymmetricMatch(-23)).toBe(false);
+ expect(falsy.asymmetricMatch(-3.1)).toBe(false);
+ });
- it("is true for a null or undefined", function() {
- var falsy = new jasmineUnderTest.Falsy(Function);
+ it('is true for a null or undefined', function() {
+ var falsy = new jasmineUnderTest.Falsy(Function);
- expect(falsy.asymmetricMatch(null)).toBe(true);
- expect(falsy.asymmetricMatch(undefined )).toBe(true);
- });
+ expect(falsy.asymmetricMatch(null)).toBe(true);
+ expect(falsy.asymmetricMatch(undefined)).toBe(true);
+ });
- it("is true for NaN", function() {
- var falsy = new jasmineUnderTest.Falsy(Object);
+ it('is true for NaN', function() {
+ var falsy = new jasmineUnderTest.Falsy(Object);
- expect(falsy.asymmetricMatch(NaN)).toBe(true);
- });
+ expect(falsy.asymmetricMatch(NaN)).toBe(true);
+ });
- it("is true for a false Boolean", function() {
- var falsy = new jasmineUnderTest.Falsy(Boolean);
+ it('is true for a false Boolean', function() {
+ var falsy = new jasmineUnderTest.Falsy(Boolean);
- expect(falsy.asymmetricMatch(false)).toBe(true);
- expect(falsy.asymmetricMatch(true)).toBe(false);
- });
+ expect(falsy.asymmetricMatch(false)).toBe(true);
+ expect(falsy.asymmetricMatch(true)).toBe(false);
+ });
});
diff --git a/spec/core/asymmetric_equality/MapContainingSpec.js b/spec/core/asymmetric_equality/MapContainingSpec.js
index dc89218..d55c450 100644
--- a/spec/core/asymmetric_equality/MapContainingSpec.js
+++ b/spec/core/asymmetric_equality/MapContainingSpec.js
@@ -1,6 +1,7 @@
/* eslint-disable compat/compat */
describe('MapContaining', function() {
- function MapI(iterable) { // for IE11
+ function MapI(iterable) {
+ // for IE11
var map = new Map();
iterable.forEach(function(kv) {
map.set(kv[0], kv[1]);
@@ -12,7 +13,6 @@
jasmine.getEnv().requireFunctioningMaps();
});
-
it('matches any actual map to an empty map', function() {
var actualMap = new MapI([['foo', 'bar']]);
var containing = new jasmineUnderTest.MapContaining(new Map());
@@ -23,14 +23,11 @@
it('matches when all the key/value pairs in sample have matches in actual', function() {
var actualMap = new MapI([
['foo', [1, 2, 3]],
- [{'foo': 'bar'}, 'baz'],
- ['other', 'any'],
+ [{ foo: 'bar' }, 'baz'],
+ ['other', 'any']
]);
- var containingMap = new MapI([
- [{'foo': 'bar'}, 'baz'],
- ['foo', [1, 2, 3]],
- ]);
+ var containingMap = new MapI([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2, 3]]]);
var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -40,13 +37,10 @@
it('does not match when a key is not in actual', function() {
var actualMap = new MapI([
['foo', [1, 2, 3]],
- [{'foo': 'not a bar'}, 'baz'],
+ [{ foo: 'not a bar' }, 'baz']
]);
- var containingMap = new MapI([
- [{'foo': 'bar'}, 'baz'],
- ['foo', [1, 2, 3]],
- ]);
+ var containingMap = new MapI([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2, 3]]]);
var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -54,15 +48,9 @@
});
it('does not match when a value is not in actual', function() {
- var actualMap = new MapI([
- ['foo', [1, 2, 3]],
- [{'foo': 'bar'}, 'baz'],
- ]);
+ var actualMap = new MapI([['foo', [1, 2, 3]], [{ foo: 'bar' }, 'baz']]);
- var containingMap = new MapI([
- [{'foo': 'bar'}, 'baz'],
- ['foo', [1, 2]],
- ]);
+ var containingMap = new MapI([[{ foo: 'bar' }, 'baz'], ['foo', [1, 2]]]);
var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -73,18 +61,12 @@
var actualMap = new MapI([
['foo1', 'not a bar'],
['foo2', 'bar'],
- ['baz', [1, 2, 3, 4]],
+ ['baz', [1, 2, 3, 4]]
]);
var containingMap = new MapI([
- [
- jasmineUnderTest.stringMatching(/^foo\d/),
- 'bar'
- ],
- [
- 'baz',
- jasmineUnderTest.arrayContaining([2, 3])
- ],
+ [jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
+ ['baz', jasmineUnderTest.arrayContaining([2, 3])]
]);
var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -93,20 +75,11 @@
});
it('does not match when a key in sample has no asymmetric matches in actual', function() {
- var actualMap = new MapI([
- ['a-foo1', 'bar'],
- ['baz', [1, 2, 3, 4]],
- ]);
+ var actualMap = new MapI([['a-foo1', 'bar'], ['baz', [1, 2, 3, 4]]]);
var containingMap = new MapI([
- [
- jasmineUnderTest.stringMatching(/^foo\d/),
- 'bar'
- ],
- [
- 'baz',
- jasmineUnderTest.arrayContaining([2, 3])
- ],
+ [jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
+ ['baz', jasmineUnderTest.arrayContaining([2, 3])]
]);
var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -115,20 +88,11 @@
});
it('does not match when a value in sample has no asymmetric matches in actual', function() {
- var actualMap = new MapI([
- ['foo1', 'bar'],
- ['baz', [1, 2, 3, 4]],
- ]);
+ var actualMap = new MapI([['foo1', 'bar'], ['baz', [1, 2, 3, 4]]]);
var containingMap = new MapI([
- [
- jasmineUnderTest.stringMatching(/^foo\d/),
- 'bar'
- ],
- [
- 'baz',
- jasmineUnderTest.arrayContaining([4, 5])
- ],
+ [jasmineUnderTest.stringMatching(/^foo\d/), 'bar'],
+ ['baz', jasmineUnderTest.arrayContaining([4, 5])]
]);
var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -140,18 +104,12 @@
var actualMap = new MapI([
['foo', new MapI([['foo1', 1], ['foo2', 2]])],
[new MapI([[1, 'bar1'], [2, 'bar2']]), 'bar'],
- ['other', 'any'],
+ ['other', 'any']
]);
var containingMap = new MapI([
- [
- 'foo',
- new jasmineUnderTest.MapContaining(new MapI([['foo1', 1]]))
- ],
- [
- new jasmineUnderTest.MapContaining(new MapI([[2, 'bar2']])),
- 'bar'
- ],
+ ['foo', new jasmineUnderTest.MapContaining(new MapI([['foo1', 1]]))],
+ [new jasmineUnderTest.MapContaining(new MapI([[2, 'bar2']])), 'bar']
]);
var containing = new jasmineUnderTest.MapContaining(containingMap);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -162,25 +120,41 @@
it('uses custom equality testers', function() {
function tester(a, b) {
// treat all negative numbers as equal
- return (typeof a == 'number' && typeof b == 'number') ? (a < 0 && b < 0) : a === b;
+ return typeof a == 'number' && typeof b == 'number'
+ ? a < 0 && b < 0
+ : a === b;
}
var actualMap = new MapI([['foo', -1]]);
- var containing = new jasmineUnderTest.MapContaining(new MapI([['foo', -2]]));
- var matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [tester]});
+ var containing = new jasmineUnderTest.MapContaining(
+ new MapI([['foo', -2]])
+ );
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: [tester]
+ });
expect(containing.asymmetricMatch(actualMap, matchersUtil)).toBe(true);
});
it('does not match when actual is not a map', function() {
var containingMap = new MapI([['foo', 'bar']]);
- expect(new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch('foo')).toBe(false);
- expect(new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch(-1)).toBe(false);
- expect(new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch({'foo': 'bar'})).toBe(false);
+ expect(
+ new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch('foo')
+ ).toBe(false);
+ expect(
+ new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch(-1)
+ ).toBe(false);
+ expect(
+ new jasmineUnderTest.MapContaining(containingMap).asymmetricMatch({
+ foo: 'bar'
+ })
+ ).toBe(false);
});
it('throws an error when sample is not a map', function() {
expect(function() {
- new jasmineUnderTest.MapContaining({'foo': 'bar'}).asymmetricMatch(new Map());
+ new jasmineUnderTest.MapContaining({ foo: 'bar' }).asymmetricMatch(
+ new Map()
+ );
}).toThrowError(/You must provide a map/);
});
diff --git a/spec/core/asymmetric_equality/NotEmptySpec.js b/spec/core/asymmetric_equality/NotEmptySpec.js
index d00ee01..fdb0a99 100644
--- a/spec/core/asymmetric_equality/NotEmptySpec.js
+++ b/spec/core/asymmetric_equality/NotEmptySpec.js
@@ -1,27 +1,27 @@
-describe("NotEmpty", function () {
- it("matches a non empty object", function () {
+describe('NotEmpty', function() {
+ it('matches a non empty object', function() {
var notEmpty = new jasmineUnderTest.NotEmpty();
- expect(notEmpty.asymmetricMatch({undefined: false})).toBe(true);
+ expect(notEmpty.asymmetricMatch({ undefined: false })).toBe(true);
expect(notEmpty.asymmetricMatch({})).toBe(false);
});
- it("matches a non empty array", function () {
+ it('matches a non empty array', function() {
var notEmpty = new jasmineUnderTest.NotEmpty();
expect(notEmpty.asymmetricMatch([1, 12, 3])).toBe(true);
expect(notEmpty.asymmetricMatch([])).toBe(false);
});
- it("matches a non empty string", function () {
+ it('matches a non empty string', function() {
var notEmpty = new jasmineUnderTest.NotEmpty();
expect(notEmpty.asymmetricMatch('12312')).toBe(true);
- expect(notEmpty.asymmetricMatch("")).toBe(false);
+ expect(notEmpty.asymmetricMatch('')).toBe(false);
expect(notEmpty.asymmetricMatch('')).toBe(false);
});
- it("matches a non empty map", function () {
+ it('matches a non empty map', function() {
jasmine.getEnv().requireFunctioningMaps();
var notEmpty = new jasmineUnderTest.NotEmpty();
var fullMap = new Map(); // eslint-disable-line compat/compat
@@ -32,7 +32,7 @@
expect(notEmpty.asymmetricMatch(emptyMap)).toBe(false);
});
- it("matches a non empty set", function () {
+ it('matches a non empty set', function() {
jasmine.getEnv().requireFunctioningSets();
var notEmpty = new jasmineUnderTest.NotEmpty();
var filledSet = new Set(); // eslint-disable-line compat/compat
@@ -43,11 +43,11 @@
expect(notEmpty.asymmetricMatch(emptySet)).toBe(false);
});
- it("matches a non empty typed array", function() {
+ it('matches a non empty typed array', function() {
jasmine.getEnv().requireFunctioningTypedArrays();
var notEmpty = new jasmineUnderTest.NotEmpty();
- expect(notEmpty.asymmetricMatch(new Int16Array([1,2,3]))).toBe(true); // eslint-disable-line compat/compat
+ expect(notEmpty.asymmetricMatch(new Int16Array([1, 2, 3]))).toBe(true); // eslint-disable-line compat/compat
expect(notEmpty.asymmetricMatch(new Int16Array())).toBe(false); // eslint-disable-line compat/compat
});
});
diff --git a/spec/core/asymmetric_equality/ObjectContainingSpec.js b/spec/core/asymmetric_equality/ObjectContainingSpec.js
index 97df255..07b8614 100644
--- a/spec/core/asymmetric_equality/ObjectContainingSpec.js
+++ b/spec/core/asymmetric_equality/ObjectContainingSpec.js
@@ -1,47 +1,55 @@
-describe("ObjectContaining", function() {
-
- it("matches any object actual to an empty object", function() {
+describe('ObjectContaining', function() {
+ it('matches any object actual to an empty object', function() {
var containing = new jasmineUnderTest.ObjectContaining({});
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(containing.asymmetricMatch({foo: 1}, matchersUtil)).toBe(true);
+ expect(containing.asymmetricMatch({ foo: 1 }, matchersUtil)).toBe(true);
});
- it("does not match when the actual is not an object", function() {
+ it('does not match when the actual is not an object', function() {
var containing = new jasmineUnderTest.ObjectContaining({});
- [1, true, undefined, "a string"].forEach(function(actual) {
+ [1, true, undefined, 'a string'].forEach(function(actual) {
expect(containing.asymmetricMatch(actual)).toBe(false);
});
});
- it("does not match an empty object actual", function() {
- var containing = new jasmineUnderTest.ObjectContaining("foo");
+ it('does not match an empty object actual', function() {
+ var containing = new jasmineUnderTest.ObjectContaining('foo');
expect(function() {
- containing.asymmetricMatch({})
- }).toThrowError(/not 'foo'/)
+ containing.asymmetricMatch({});
+ }).toThrowError(/not 'foo'/);
});
- it("matches when the key/value pair is present in the actual", function() {
- var containing = new jasmineUnderTest.ObjectContaining({foo: "fooVal"});
+ it('matches when the key/value pair is present in the actual', function() {
+ var containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' });
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(containing.asymmetricMatch({foo: "fooVal", bar: "barVal"}, matchersUtil)).toBe(true);
+ expect(
+ containing.asymmetricMatch({ foo: 'fooVal', bar: 'barVal' }, matchersUtil)
+ ).toBe(true);
});
- it("does not match when the key/value pair is not present in the actual", function() {
- var containing = new jasmineUnderTest.ObjectContaining({foo: "fooVal"});
+ it('does not match when the key/value pair is not present in the actual', function() {
+ var containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' });
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(containing.asymmetricMatch({bar: "barVal", quux: "quuxVal"}, matchersUtil)).toBe(false);
+ expect(
+ containing.asymmetricMatch(
+ { bar: 'barVal', quux: 'quuxVal' },
+ matchersUtil
+ )
+ ).toBe(false);
});
- it("does not match when the key is present but the value is different in the actual", function() {
- var containing = new jasmineUnderTest.ObjectContaining({foo: "other"});
+ it('does not match when the key is present but the value is different in the actual', function() {
+ var containing = new jasmineUnderTest.ObjectContaining({ foo: 'other' });
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(containing.asymmetricMatch({foo: "fooVal", bar: "barVal"}, matchersUtil)).toBe(false);
+ expect(
+ containing.asymmetricMatch({ foo: 'fooVal', bar: 'barVal' }, matchersUtil)
+ ).toBe(false);
});
it("jasmineToString's itself", function() {
@@ -53,46 +61,55 @@
'<jasmine.objectContaining(sample)>'
);
expect(pp).toHaveBeenCalledWith(sample);
-
});
- it("matches recursively", function() {
- var containing = new jasmineUnderTest.ObjectContaining({one: new jasmineUnderTest.ObjectContaining({two: {}})});
+ it('matches recursively', function() {
+ var containing = new jasmineUnderTest.ObjectContaining({
+ one: new jasmineUnderTest.ObjectContaining({ two: {} })
+ });
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(containing.asymmetricMatch({one: {two: {}}}, matchersUtil)).toBe(true);
+ expect(containing.asymmetricMatch({ one: { two: {} } }, matchersUtil)).toBe(
+ true
+ );
});
- it("matches when key is present with undefined value", function() {
+ it('matches when key is present with undefined value', function() {
var containing = new jasmineUnderTest.ObjectContaining({ one: undefined });
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(containing.asymmetricMatch({ one: undefined }, matchersUtil)).toBe(true);
+ expect(containing.asymmetricMatch({ one: undefined }, matchersUtil)).toBe(
+ true
+ );
});
- it("does not match when key with undefined value is not present", function() {
+ it('does not match when key with undefined value is not present', function() {
var containing = new jasmineUnderTest.ObjectContaining({ one: undefined });
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(containing.asymmetricMatch({}, matchersUtil)).toBe(false);
});
- it("matches defined properties", function(){
- var containing = new jasmineUnderTest.ObjectContaining({ foo: "fooVal" });
+ it('matches defined properties', function() {
+ var containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' });
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var definedPropertyObject = {};
- Object.defineProperty(definedPropertyObject, "foo", {
- get: function() { return "fooVal" }
+ Object.defineProperty(definedPropertyObject, 'foo', {
+ get: function() {
+ return 'fooVal';
+ }
});
- expect(containing.asymmetricMatch(definedPropertyObject, matchersUtil)).toBe(true);
+ expect(
+ containing.asymmetricMatch(definedPropertyObject, matchersUtil)
+ ).toBe(true);
});
- it("matches prototype properties", function(){
- var containing = new jasmineUnderTest.ObjectContaining({ foo: "fooVal" });
+ it('matches prototype properties', function() {
+ var containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' });
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- var prototypeObject = {foo: "fooVal"};
+ var prototypeObject = { foo: 'fooVal' };
var obj;
if (Object.create) {
@@ -107,23 +124,31 @@
expect(containing.asymmetricMatch(obj, matchersUtil)).toBe(true);
});
- it("uses custom equality testers", function() {
+ it('uses custom equality testers', function() {
var tester = function(a, b) {
// All "foo*" strings match each other.
- if (typeof a == "string" && typeof b == "string" &&
- a.substr(0, 3) == "foo" && b.substr(0, 3) == "foo") {
+ if (
+ typeof a == 'string' &&
+ typeof b == 'string' &&
+ a.substr(0, 3) == 'foo' &&
+ b.substr(0, 3) == 'foo'
+ ) {
return true;
}
};
- var containing = new jasmineUnderTest.ObjectContaining({foo: "fooVal"});
- var matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [tester]});
+ var containing = new jasmineUnderTest.ObjectContaining({ foo: 'fooVal' });
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: [tester]
+ });
- expect(containing.asymmetricMatch({foo: "fooBar"}, matchersUtil)).toBe(true);
+ expect(containing.asymmetricMatch({ foo: 'fooBar' }, matchersUtil)).toBe(
+ true
+ );
});
- describe("valuesForDiff_", function() {
- describe("when other is not an object", function() {
- it("sets self to jasmineToString()", function () {
+ describe('valuesForDiff_', function() {
+ describe('when other is not an object', function() {
+ it('sets self to jasmineToString()', function() {
var containing = new jasmineUnderTest.ObjectContaining({}),
pp = jasmineUnderTest.makePrettyPrinter(),
result = containing.valuesForDiff_('a', pp);
@@ -135,27 +160,31 @@
});
});
- describe("when other is an object", function() {
- it("includes keys that are present in both other and sample", function() {
- var sample = {a: 1, b: 2},
- other = {a: 3, b: 4},
+ describe('when other is an object', function() {
+ it('includes keys that are present in both other and sample', function() {
+ var sample = { a: 1, b: 2 },
+ other = { a: 3, b: 4 },
containing = new jasmineUnderTest.ObjectContaining(sample),
result = containing.valuesForDiff_(other);
- expect(result.self).not.toBeInstanceOf(jasmineUnderTest.ObjectContaining);
+ expect(result.self).not.toBeInstanceOf(
+ jasmineUnderTest.ObjectContaining
+ );
expect(result).toEqual({
self: sample,
other: other
});
});
- it("includes keys that are present only in sample", function() {
- var sample = {a: 1, b: 2},
- other = {a: 3},
+ it('includes keys that are present only in sample', function() {
+ var sample = { a: 1, b: 2 },
+ other = { a: 3 },
containing = new jasmineUnderTest.ObjectContaining(sample),
result = containing.valuesForDiff_(other);
- expect(result.self).not.toBeInstanceOf(jasmineUnderTest.ObjectContaining);
+ expect(result.self).not.toBeInstanceOf(
+ jasmineUnderTest.ObjectContaining
+ );
expect(containing.valuesForDiff_(other)).toEqual({
self: sample,
other: {
@@ -165,13 +194,15 @@
});
});
- it("omits keys that are present only in other", function() {
- var sample = {a: 1, b: 2},
- other = {a: 3, b: 4, c: 5},
+ it('omits keys that are present only in other', function() {
+ var sample = { a: 1, b: 2 },
+ other = { a: 3, b: 4, c: 5 },
containing = new jasmineUnderTest.ObjectContaining(sample),
result = containing.valuesForDiff_(other);
- expect(result.self).not.toBeInstanceOf(jasmineUnderTest.ObjectContaining);
+ expect(result.self).not.toBeInstanceOf(
+ jasmineUnderTest.ObjectContaining
+ );
expect(result).toEqual({
self: sample,
other: {
diff --git a/spec/core/asymmetric_equality/SetContainingSpec.js b/spec/core/asymmetric_equality/SetContainingSpec.js
index 3f7b1b1..37925c4 100644
--- a/spec/core/asymmetric_equality/SetContainingSpec.js
+++ b/spec/core/asymmetric_equality/SetContainingSpec.js
@@ -1,6 +1,7 @@
/* eslint-disable compat/compat */
describe('SetContaining', function() {
- function SetI(iterable) { // for IE11
+ function SetI(iterable) {
+ // for IE11
var set = new Set();
iterable.forEach(function(v) {
set.add(v);
@@ -12,7 +13,6 @@
jasmine.getEnv().requireFunctioningSets();
});
-
it('matches any actual set to an empty set', function() {
var actualSet = new SetI(['foo', 'bar']);
var containing = new jasmineUnderTest.SetContaining(new Set());
@@ -21,13 +21,9 @@
});
it('matches when all the values in sample have matches in actual', function() {
- var actualSet = new SetI([
- {'foo': 'bar'}, 'baz', [1, 2, 3]
- ]);
+ var actualSet = new SetI([{ foo: 'bar' }, 'baz', [1, 2, 3]]);
- var containingSet = new SetI([
- [1, 2, 3], {'foo': 'bar'}
- ]);
+ var containingSet = new SetI([[1, 2, 3], { foo: 'bar' }]);
var containing = new jasmineUnderTest.SetContaining(containingSet);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -35,13 +31,9 @@
});
it('does not match when a value is not in actual', function() {
- var actualSet = new SetI([
- {'foo': 'bar'}, 'baz', [1, 2, 3]
- ]);
+ var actualSet = new SetI([{ foo: 'bar' }, 'baz', [1, 2, 3]]);
- var containingSet = new SetI([
- [1, 2], {'foo': 'bar'}
- ]);
+ var containingSet = new SetI([[1, 2], { foo: 'bar' }]);
var containing = new jasmineUnderTest.SetContaining(containingSet);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -49,13 +41,11 @@
});
it('matches when all the values in sample have asymmetric matches in actual', function() {
- var actualSet = new SetI([
- [1, 2, 3, 4], 'other', 'foo1'
- ]);
+ var actualSet = new SetI([[1, 2, 3, 4], 'other', 'foo1']);
var containingSet = new SetI([
jasmineUnderTest.stringMatching(/^foo\d/),
- jasmineUnderTest.arrayContaining([2, 3]),
+ jasmineUnderTest.arrayContaining([2, 3])
]);
var containing = new jasmineUnderTest.SetContaining(containingSet);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -64,13 +54,11 @@
});
it('does not match when a value in sample has no asymmetric matches in actual', function() {
- var actualSet = new SetI([
- 'a-foo1', [1, 2, 3, 4], 'other'
- ]);
+ var actualSet = new SetI(['a-foo1', [1, 2, 3, 4], 'other']);
var containingSet = new SetI([
jasmine.stringMatching(/^foo\d/),
- jasmine.arrayContaining([2, 3]),
+ jasmine.arrayContaining([2, 3])
]);
var containing = new jasmineUnderTest.SetContaining(containingSet);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -79,12 +67,11 @@
});
it('matches recursively', function() {
- var actualSet = new SetI([
- 'foo', new SetI([1, 'bar', 2]), 'other'
- ]);
+ var actualSet = new SetI(['foo', new SetI([1, 'bar', 2]), 'other']);
var containingSet = new SetI([
- new jasmineUnderTest.SetContaining(new SetI(['bar'])), 'foo'
+ new jasmineUnderTest.SetContaining(new SetI(['bar'])),
+ 'foo'
]);
var containing = new jasmineUnderTest.SetContaining(containingSet);
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -95,25 +82,37 @@
it('uses custom equality testers', function() {
function tester(a, b) {
// treat all negative numbers as equal
- return (typeof a == 'number' && typeof b == 'number') ? (a < 0 && b < 0) : a === b;
+ return typeof a == 'number' && typeof b == 'number'
+ ? a < 0 && b < 0
+ : a === b;
}
var actualSet = new SetI(['foo', -1]);
var containing = new jasmineUnderTest.SetContaining(new SetI([-2, 'foo']));
- var matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [tester]});
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: [tester]
+ });
expect(containing.asymmetricMatch(actualSet, matchersUtil)).toBe(true);
});
it('does not match when actual is not a set', function() {
var containingSet = new SetI(['foo']);
- expect(new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch('foo')).toBe(false);
- expect(new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch(1)).toBe(false);
- expect(new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch(['foo'])).toBe(false);
+ expect(
+ new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch('foo')
+ ).toBe(false);
+ expect(
+ new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch(1)
+ ).toBe(false);
+ expect(
+ new jasmineUnderTest.SetContaining(containingSet).asymmetricMatch(['foo'])
+ ).toBe(false);
});
it('throws an error when sample is not a set', function() {
expect(function() {
- new jasmineUnderTest.SetContaining({'foo': 'bar'}).asymmetricMatch(new Set());
+ new jasmineUnderTest.SetContaining({ foo: 'bar' }).asymmetricMatch(
+ new Set()
+ );
}).toThrowError(/You must provide a set/);
});
diff --git a/spec/core/asymmetric_equality/StringMatchingSpec.js b/spec/core/asymmetric_equality/StringMatchingSpec.js
index 9c231b7..656b0e5 100644
--- a/spec/core/asymmetric_equality/StringMatchingSpec.js
+++ b/spec/core/asymmetric_equality/StringMatchingSpec.js
@@ -1,19 +1,19 @@
-describe("StringMatching", function() {
- it("matches a string against a provided regexp", function() {
+describe('StringMatching', function() {
+ it('matches a string against a provided regexp', function() {
var matcher = new jasmineUnderTest.StringMatching(/foo/);
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
});
- it("matches a string against provided string", function() {
+ it('matches a string against provided string', function() {
var matcher = new jasmineUnderTest.StringMatching('foo');
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
});
- it("raises an Error when the expected is not a String or RegExp", function() {
+ it('raises an Error when the expected is not a String or RegExp', function() {
expect(function() {
new jasmineUnderTest.StringMatching({});
}).toThrowError(/not a String or a RegExp/);
@@ -22,6 +22,8 @@
it("jasmineToString's itself", function() {
var matching = new jasmineUnderTest.StringMatching(/^foo/);
- expect(matching.jasmineToString()).toEqual("<jasmine.stringMatching(/^foo/)>");
+ expect(matching.jasmineToString()).toEqual(
+ '<jasmine.stringMatching(/^foo/)>'
+ );
});
});
diff --git a/spec/core/asymmetric_equality/TruthySpec.js b/spec/core/asymmetric_equality/TruthySpec.js
index af1bdde..b2ac277 100644
--- a/spec/core/asymmetric_equality/TruthySpec.js
+++ b/spec/core/asymmetric_equality/TruthySpec.js
@@ -1,12 +1,12 @@
-describe("Truthy", function () {
- it("is true for a non empty string", function () {
+describe('Truthy', function() {
+ it('is true for a non empty string', function() {
var truthy = new jasmineUnderTest.Truthy();
- expect(truthy.asymmetricMatch("foo")).toBe(true);
- expect(truthy.asymmetricMatch("")).toBe(false);
+ expect(truthy.asymmetricMatch('foo')).toBe(true);
+ expect(truthy.asymmetricMatch('')).toBe(false);
});
- it("is true for a number that is not 0", function () {
+ it('is true for a number that is not 0', function() {
var truthy = new jasmineUnderTest.Truthy();
expect(truthy.asymmetricMatch(1)).toBe(true);
@@ -15,49 +15,47 @@
expect(truthy.asymmetricMatch(-3.1)).toBe(true);
});
- it("is true for a function", function () {
+ it('is true for a function', function() {
var truthy = new jasmineUnderTest.Truthy();
- expect(truthy.asymmetricMatch(function () {
- })).toBe(true);
+ expect(truthy.asymmetricMatch(function() {})).toBe(true);
});
- it("is true for an Object", function () {
+ it('is true for an Object', function() {
var truthy = new jasmineUnderTest.Truthy();
expect(truthy.asymmetricMatch({})).toBe(true);
});
- it("is true for a truthful Boolean", function () {
+ it('is true for a truthful Boolean', function() {
var truthy = new jasmineUnderTest.Truthy();
expect(truthy.asymmetricMatch(true)).toBe(true);
expect(truthy.asymmetricMatch(false)).toBe(false);
});
- it("is true for an empty object", function () {
+ it('is true for an empty object', function() {
var truthy = new jasmineUnderTest.Truthy();
expect(truthy.asymmetricMatch({})).toBe(true);
});
- it("is true for an empty array", function () {
+ it('is true for an empty array', function() {
var truthy = new jasmineUnderTest.Truthy();
expect(truthy.asymmetricMatch([])).toBe(true);
});
- it("is true for a date", function () {
+ it('is true for a date', function() {
var truthy = new jasmineUnderTest.Truthy();
expect(truthy.asymmetricMatch(new Date())).toBe(true);
});
- it("is true for a infiniti", function () {
+ it('is true for a infiniti', function() {
var truthy = new jasmineUnderTest.Truthy();
expect(truthy.asymmetricMatch(Infinity)).toBe(true);
expect(truthy.asymmetricMatch(-Infinity)).toBe(true);
});
});
-
diff --git a/spec/core/integration/AsymmetricEqualityTestersSpec.js b/spec/core/integration/AsymmetricEqualityTestersSpec.js
index 1ccf280..8007f87 100644
--- a/spec/core/integration/AsymmetricEqualityTestersSpec.js
+++ b/spec/core/integration/AsymmetricEqualityTestersSpec.js
@@ -1,12 +1,12 @@
-describe('Asymmetric equality testers (Integration)', function () {
+describe('Asymmetric equality testers (Integration)', function() {
function verifyPasses(expectations, setup) {
- it('passes', function (done) {
+ it('passes', function(done) {
var env = new jasmineUnderTest.Env();
- env.it('a spec', function () {
+ env.it('a spec', function() {
expectations(env);
});
- var specExpectations = function (result) {
+ var specExpectations = function(result) {
expect(result.status).toEqual('passed');
expect(result.passedExpectations.length)
.withContext('Number of passed expectations')
@@ -14,115 +14,122 @@
expect(result.failedExpectations.length)
.withContext('Number of failed expectations')
.toEqual(0);
- expect(result.failedExpectations[0] && result.failedExpectations[0].message)
+ expect(
+ result.failedExpectations[0] && result.failedExpectations[0].message
+ )
.withContext('Failure message')
.toBeUndefined();
};
- env.addReporter({specDone: specExpectations, jasmineDone: done});
+ env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
}
function verifyFails(expectations) {
- it('fails', function (done) {
+ it('fails', function(done) {
var env = new jasmineUnderTest.Env();
- env.it('a spec', function () {
+ env.it('a spec', function() {
expectations(env);
});
- var specExpectations = function (result) {
+ var specExpectations = function(result) {
expect(result.status).toEqual('failed');
expect(result.failedExpectations.length)
.withContext('Number of failed expectations')
.toEqual(1);
expect(result.failedExpectations[0].message)
- .withContext('Failed with a thrown error rather than a matcher failure')
+ .withContext(
+ 'Failed with a thrown error rather than a matcher failure'
+ )
.not.toMatch(/^Error: /);
- expect(result.failedExpectations[0].matcherName).withContext('Matcher name')
+ expect(result.failedExpectations[0].matcherName)
+ .withContext('Matcher name')
.not.toEqual('');
};
- env.addReporter({specDone: specExpectations, jasmineDone: done});
+ env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
}
- describe('any', function () {
- verifyPasses(function (env) {
+ describe('any', function() {
+ verifyPasses(function(env) {
env.expect(5).toEqual(jasmineUnderTest.any(Number));
});
- verifyFails(function (env) {
- env.expect("five").toEqual(jasmineUnderTest.any(Number));
+ verifyFails(function(env) {
+ env.expect('five').toEqual(jasmineUnderTest.any(Number));
});
});
- describe('anything', function () {
- verifyPasses(function (env) {
+ describe('anything', function() {
+ verifyPasses(function(env) {
env.expect('').toEqual(jasmineUnderTest.anything());
});
- verifyFails(function (env) {
+ verifyFails(function(env) {
env.expect(null).toEqual(jasmineUnderTest.anything());
});
});
- describe('arrayContaining', function () {
- verifyPasses(function (env) {
- env.addCustomEqualityTester(function (a, b) {
+ describe('arrayContaining', function() {
+ verifyPasses(function(env) {
+ env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
- env.expect([1, 2, 3]).toEqual(jasmineUnderTest.arrayContaining(["2"]));
+ env.expect([1, 2, 3]).toEqual(jasmineUnderTest.arrayContaining(['2']));
});
- verifyFails(function (env) {
+ verifyFails(function(env) {
env.expect(null).toEqual(jasmineUnderTest.arrayContaining([2]));
});
});
- describe('arrayWithExactContents', function () {
- verifyPasses(function (env) {
- env.addCustomEqualityTester(function (a, b) {
+ describe('arrayWithExactContents', function() {
+ verifyPasses(function(env) {
+ env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
- env.expect([1, 2]).toEqual(jasmineUnderTest.arrayWithExactContents(["2", "1"]));
+ env
+ .expect([1, 2])
+ .toEqual(jasmineUnderTest.arrayWithExactContents(['2', '1']));
});
- verifyFails(function (env) {
+ verifyFails(function(env) {
env.expect([]).toEqual(jasmineUnderTest.arrayWithExactContents([2]));
});
});
- describe('empty', function () {
- verifyPasses(function (env) {
+ describe('empty', function() {
+ verifyPasses(function(env) {
env.expect([]).toEqual(jasmineUnderTest.empty());
});
- verifyFails(function (env) {
+ verifyFails(function(env) {
env.expect([1]).toEqual(jasmineUnderTest.empty());
});
});
- describe('falsy', function () {
- verifyPasses(function (env) {
+ describe('falsy', function() {
+ verifyPasses(function(env) {
env.expect(false).toEqual(jasmineUnderTest.falsy());
});
- verifyFails(function (env) {
+ verifyFails(function(env) {
env.expect(true).toEqual(jasmineUnderTest.falsy());
});
});
- describe('mapContaining', function () {
+ describe('mapContaining', function() {
if (jasmine.getEnv().hasFunctioningMaps()) {
- verifyPasses(function (env) {
+ verifyPasses(function(env) {
var actual = new Map();
- actual.set('a', "2");
+ actual.set('a', '2');
var expected = new Map();
expected.set('a', 2);
- env.addCustomEqualityTester(function (a, b) {
+ env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
@@ -130,54 +137,62 @@
});
} else {
it('passes', function() {
- jasmine.getEnv().pending('Browser has incomplete or missing support for Maps');
+ jasmine
+ .getEnv()
+ .pending('Browser has incomplete or missing support for Maps');
});
}
if (jasmine.getEnv().hasFunctioningMaps()) {
- verifyFails(function (env) {
- env.expect('something').toEqual(jasmineUnderTest.mapContaining(new Map()));
+ verifyFails(function(env) {
+ env
+ .expect('something')
+ .toEqual(jasmineUnderTest.mapContaining(new Map()));
});
} else {
it('fails', function() {
- jasmine.getEnv().pending('Browser has incomplete or missing support for Maps');
+ jasmine
+ .getEnv()
+ .pending('Browser has incomplete or missing support for Maps');
});
}
});
- describe('notEmpty', function () {
- verifyPasses(function (env) {
+ describe('notEmpty', function() {
+ verifyPasses(function(env) {
env.expect([1]).toEqual(jasmineUnderTest.notEmpty());
});
- verifyFails(function (env) {
+ verifyFails(function(env) {
env.expect([]).toEqual(jasmineUnderTest.notEmpty());
});
});
- describe('objectContaining', function () {
- verifyPasses(function (env) {
- env.addCustomEqualityTester(function (a, b) {
+ describe('objectContaining', function() {
+ verifyPasses(function(env) {
+ env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
- env.expect({a: 1, b: 2}).toEqual(jasmineUnderTest.objectContaining({a: "1"}));
+ env
+ .expect({ a: 1, b: 2 })
+ .toEqual(jasmineUnderTest.objectContaining({ a: '1' }));
});
- verifyFails(function (env) {
- env.expect({}).toEqual(jasmineUnderTest.objectContaining({a: "1"}));
+ verifyFails(function(env) {
+ env.expect({}).toEqual(jasmineUnderTest.objectContaining({ a: '1' }));
});
});
- describe('setContaining', function () {
+ describe('setContaining', function() {
if (jasmine.getEnv().hasFunctioningSets()) {
- verifyPasses(function (env) {
+ verifyPasses(function(env) {
var actual = new Set();
- actual.add("1");
+ actual.add('1');
var expected = new Set();
actual.add(1);
- env.addCustomEqualityTester(function (a, b) {
+ env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
@@ -185,37 +200,43 @@
});
} else {
it('pases', function() {
- jasmine.getEnv().pending('Browser has incomplete or missing support for Sets');
+ jasmine
+ .getEnv()
+ .pending('Browser has incomplete or missing support for Sets');
});
}
if (jasmine.getEnv().hasFunctioningSets()) {
- verifyFails(function (env) {
- env.expect('something').toEqual(jasmineUnderTest.setContaining(new Set()));
+ verifyFails(function(env) {
+ env
+ .expect('something')
+ .toEqual(jasmineUnderTest.setContaining(new Set()));
});
} else {
it('fails', function() {
- jasmine.getEnv().pending('Browser has incomplete or missing support for Sets');
+ jasmine
+ .getEnv()
+ .pending('Browser has incomplete or missing support for Sets');
});
}
});
- describe('stringMatching', function () {
- verifyPasses(function (env) {
+ describe('stringMatching', function() {
+ verifyPasses(function(env) {
env.expect('foo').toEqual(jasmineUnderTest.stringMatching(/o/));
});
- verifyFails(function (env) {
+ verifyFails(function(env) {
env.expect('bar').toEqual(jasmineUnderTest.stringMatching(/o/));
});
});
- describe('truthy', function () {
- verifyPasses(function (env) {
+ describe('truthy', function() {
+ verifyPasses(function(env) {
env.expect(true).toEqual(jasmineUnderTest.truthy());
});
- verifyFails(function (env) {
+ verifyFails(function(env) {
env.expect(false).toEqual(jasmineUnderTest.truthy());
});
});
diff --git a/spec/core/integration/CustomAsyncMatchersSpec.js b/spec/core/integration/CustomAsyncMatchersSpec.js
index 1b60bb4..cf67092 100644
--- a/spec/core/integration/CustomAsyncMatchersSpec.js
+++ b/spec/core/integration/CustomAsyncMatchersSpec.js
@@ -4,7 +4,7 @@
beforeEach(function() {
env = new jasmineUnderTest.Env();
- env.configure({random: false});
+ env.configure({ random: false });
});
afterEach(function() {
@@ -17,7 +17,11 @@
env.it('spec using custom async matcher', function() {
env.addAsyncMatchers({
toBeReal: function() {
- return { compare: function() { return Promise.resolve({ pass: true }); } };
+ return {
+ compare: function() {
+ return Promise.resolve({ pass: true });
+ }
+ };
}
});
@@ -39,8 +43,12 @@
env.addAsyncMatchers({
toBeReal: function() {
return {
- compare: function() { return Promise.resolve({ pass: true }); },
- negativeCompare: function() { return Promise.resolve({ pass: true }); }
+ compare: function() {
+ return Promise.resolve({ pass: true });
+ },
+ negativeCompare: function() {
+ return Promise.resolve({ pass: true });
+ }
};
}
});
@@ -74,7 +82,9 @@
});
var specExpectations = function(result) {
- expect(result.failedExpectations[0].message).toEqual("Expected 'a' to be real.");
+ expect(result.failedExpectations[0].message).toEqual(
+ "Expected 'a' to be real."
+ );
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
@@ -82,22 +92,24 @@
});
// TODO: remove this in the next major release.
- it("passes the jasmine utility and current equality testers to the matcher factory", function(done) {
+ it('passes the jasmine utility and current equality testers to the matcher factory', function(done) {
jasmine.getEnv().requirePromises();
- var matcherFactory = function () {
+ var matcherFactory = function() {
return {
- compare: function () {
- return Promise.resolve({pass: true});
+ compare: function() {
+ return Promise.resolve({ pass: true });
}
};
},
- matcherFactorySpy = jasmine.createSpy("matcherFactorySpy").and.callFake(matcherFactory),
- customEqualityFn = function () {
+ matcherFactorySpy = jasmine
+ .createSpy('matcherFactorySpy')
+ .and.callFake(matcherFactory),
+ customEqualityFn = function() {
return true;
};
- env.it("spec with expectation", function() {
+ env.it('spec with expectation', function() {
env.addCustomEqualityTester(customEqualityFn);
env.addAsyncMatchers({
toBeReal: matcherFactorySpy
@@ -117,31 +129,35 @@
env.execute();
});
- it("provides custom equality testers to the matcher factory via matchersUtil", function(done) {
+ it('provides custom equality testers to the matcher factory via matchersUtil', function(done) {
jasmine.getEnv().requirePromises();
- var matcherFactory = function (matchersUtil) {
+ var matcherFactory = function(matchersUtil) {
return {
- compare: function (actual, expected) {
- return Promise.resolve({pass: matchersUtil.equals(actual[0], expected)});
+ compare: function(actual, expected) {
+ return Promise.resolve({
+ pass: matchersUtil.equals(actual[0], expected)
+ });
}
};
},
- customEqualityFn = jasmine.createSpy("customEqualityFn").and.callFake(function (a, b) {
- return a.toString() === b;
- });
+ customEqualityFn = jasmine
+ .createSpy('customEqualityFn')
+ .and.callFake(function(a, b) {
+ return a.toString() === b;
+ });
- env.it("spec with expectation", function() {
+ env.it('spec with expectation', function() {
env.addCustomEqualityTester(customEqualityFn);
env.addAsyncMatchers({
toBeArrayWithFirstElement: matcherFactory
});
- return env.expectAsync([1, 2]).toBeArrayWithFirstElement("1");
+ return env.expectAsync([1, 2]).toBeArrayWithFirstElement('1');
});
var specExpectations = function(result) {
- expect(customEqualityFn).toHaveBeenCalledWith(1, "1");
+ expect(customEqualityFn).toHaveBeenCalledWith(1, '1');
expect(result.failedExpectations).toEqual([]);
};
diff --git a/spec/core/integration/CustomMatchersSpec.js b/spec/core/integration/CustomMatchersSpec.js
index c981294..b27e18d 100644
--- a/spec/core/integration/CustomMatchersSpec.js
+++ b/spec/core/integration/CustomMatchersSpec.js
@@ -1,52 +1,65 @@
-describe("Custom Matchers (Integration)", function () {
+describe('Custom Matchers (Integration)', function() {
var env;
var fakeTimer;
- beforeEach(function () {
+ beforeEach(function() {
env = new jasmineUnderTest.Env();
- env.configure({random: false});
+ env.configure({ random: false });
});
afterEach(function() {
env.cleanup_();
});
- it("allows adding more matchers local to a spec", function (done) {
- env.it('spec defining a custom matcher', function () {
+ it('allows adding more matchers local to a spec', function(done) {
+ env.it('spec defining a custom matcher', function() {
env.addMatchers({
- matcherForSpec: function () {
+ matcherForSpec: function() {
return {
- compare: function (actual, expected) {
- return {pass: false, message: "matcherForSpec: actual: " + actual + "; expected: " + expected};
+ compare: function(actual, expected) {
+ return {
+ pass: false,
+ message:
+ 'matcherForSpec: actual: ' +
+ actual +
+ '; expected: ' +
+ expected
+ };
}
- }
+ };
}
});
- env.expect("zzz").matcherForSpec("yyy");
+ env.expect('zzz').matcherForSpec('yyy');
});
- env.it("spec without custom matcher defined", function() {
- expect(env.expect("zzz").matcherForSpec).toBeUndefined();
+ env.it('spec without custom matcher defined', function() {
+ expect(env.expect('zzz').matcherForSpec).toBeUndefined();
});
- var specDoneSpy = jasmine.createSpy("specDoneSpy");
+ var specDoneSpy = jasmine.createSpy('specDoneSpy');
var expectations = function() {
var firstSpecResult = specDoneSpy.calls.first().args[0];
- expect(firstSpecResult.status).toEqual("failed");
- expect(firstSpecResult.failedExpectations[0].message).toEqual("matcherForSpec: actual: zzz; expected: yyy");
+ expect(firstSpecResult.status).toEqual('failed');
+ expect(firstSpecResult.failedExpectations[0].message).toEqual(
+ 'matcherForSpec: actual: zzz; expected: yyy'
+ );
done();
};
- env.addReporter({ specDone:specDoneSpy, jasmineDone: expectations});
+ env.addReporter({ specDone: specDoneSpy, jasmineDone: expectations });
env.execute();
});
- it("passes the spec if the custom matcher passes", function(done) {
- env.it("spec using custom matcher", function() {
+ it('passes the spec if the custom matcher passes', function(done) {
+ env.it('spec using custom matcher', function() {
env.addMatchers({
toBeReal: function() {
- return { compare: function() { return { pass: true }; } };
+ return {
+ compare: function() {
+ return { pass: true };
+ }
+ };
}
});
@@ -61,20 +74,30 @@
env.execute();
});
- it("passes the spec if the custom equality matcher passes for types nested inside asymmetric equality testers", function(done) {
- env.it("spec using custom equality matcher", function() {
+ it('passes the spec if the custom equality matcher passes for types nested inside asymmetric equality testers', function(done) {
+ env.it('spec using custom equality matcher', function() {
var customEqualityFn = function(a, b) {
// All "foo*" strings match each other.
- if (typeof a == "string" && typeof b == "string" &&
- a.substr(0, 3) == "foo" && b.substr(0, 3) == "foo") {
+ if (
+ typeof a == 'string' &&
+ typeof b == 'string' &&
+ a.substr(0, 3) == 'foo' &&
+ b.substr(0, 3) == 'foo'
+ ) {
return true;
}
};
env.addCustomEqualityTester(customEqualityFn);
- env.expect({foo: 'fooValue'}).toEqual(jasmineUnderTest.objectContaining({foo: 'fooBar'}));
- env.expect(['fooValue', 'things']).toEqual(jasmineUnderTest.arrayContaining(['fooBar']));
- env.expect(['fooValue']).toEqual(jasmineUnderTest.arrayWithExactContents(['fooBar']));
+ env
+ .expect({ foo: 'fooValue' })
+ .toEqual(jasmineUnderTest.objectContaining({ foo: 'fooBar' }));
+ env
+ .expect(['fooValue', 'things'])
+ .toEqual(jasmineUnderTest.arrayContaining(['fooBar']));
+ env
+ .expect(['fooValue'])
+ .toEqual(jasmineUnderTest.arrayWithExactContents(['fooBar']));
});
var specExpectations = function(result) {
@@ -85,26 +108,30 @@
env.execute();
});
- it("supports asymmetric equality testers that take a list of custom equality testers", function(done) {
+ it('supports asymmetric equality testers that take a list of custom equality testers', function(done) {
// TODO: remove this in the next major release.
spyOn(jasmineUnderTest, 'getEnv').and.returnValue(env);
- env.it("spec using custom asymmetric equality tester", function() {
+ env.it('spec using custom asymmetric equality tester', function() {
var customEqualityFn = function(a, b) {
- if (a === 2 && b === "two") {
+ if (a === 2 && b === 'two') {
return true;
}
};
var arrayWithFirstElement = function(sample) {
return {
- asymmetricMatch: function (actual, customEqualityTesters) {
- return jasmineUnderTest.matchersUtil.equals(sample, actual[0], customEqualityTesters);
+ asymmetricMatch: function(actual, customEqualityTesters) {
+ return jasmineUnderTest.matchersUtil.equals(
+ sample,
+ actual[0],
+ customEqualityTesters
+ );
}
};
};
env.addCustomEqualityTester(customEqualityFn);
- env.expect(["two"]).toEqual(arrayWithFirstElement(2));
+ env.expect(['two']).toEqual(arrayWithFirstElement(2));
});
var specExpectations = function(result) {
@@ -115,8 +142,8 @@
env.execute();
});
- it("displays an appropriate failure message if a custom equality matcher fails", function(done) {
- env.it("spec using custom equality matcher", function() {
+ it('displays an appropriate failure message if a custom equality matcher fails', function(done) {
+ env.it('spec using custom equality matcher', function() {
var customEqualityFn = function(a, b) {
// "foo" is not equal to anything
if (a === 'foo' || b === 'foo') {
@@ -125,7 +152,7 @@
};
env.addCustomEqualityTester(customEqualityFn);
- env.expect({foo: 'foo'}).toEqual({foo: 'foo'});
+ env.expect({ foo: 'foo' }).toEqual({ foo: 'foo' });
});
var specExpectations = function(result) {
@@ -139,13 +166,17 @@
env.execute();
});
- it("uses the negative compare function for a negative comparison, if provided", function(done) {
- env.it("spec with custom negative comparison matcher", function() {
+ it('uses the negative compare function for a negative comparison, if provided', function(done) {
+ env.it('spec with custom negative comparison matcher', function() {
env.addMatchers({
toBeReal: function() {
return {
- compare: function() { return { pass: true }; },
- negativeCompare: function() { return { pass: true }; }
+ compare: function() {
+ return { pass: true };
+ },
+ negativeCompare: function() {
+ return { pass: true };
+ }
};
}
});
@@ -161,7 +192,7 @@
env.execute();
});
- it("generates messages with the same rules as built in matchers absent a custom message", function(done) {
+ it('generates messages with the same rules as built in matchers absent a custom message', function(done) {
env.it('spec with an expectation', function() {
env.addMatchers({
toBeReal: function() {
@@ -169,25 +200,29 @@
compare: function() {
return { pass: false };
}
- }
+ };
}
});
- env.expect("a").toBeReal();
+ env.expect('a').toBeReal();
});
var specExpectations = function(result) {
- expect(result.failedExpectations[0].message).toEqual("Expected 'a' to be real.");
+ expect(result.failedExpectations[0].message).toEqual(
+ "Expected 'a' to be real."
+ );
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
- it("passes the expected and actual arguments to the comparison function", function(done) {
- var argumentSpy = jasmine.createSpy("argument spy").and.returnValue({ pass: true });
+ it('passes the expected and actual arguments to the comparison function', function(done) {
+ var argumentSpy = jasmine
+ .createSpy('argument spy')
+ .and.returnValue({ pass: true });
- env.it('spec with an expectation', function () {
+ env.it('spec with an expectation', function() {
env.addMatchers({
toBeReal: function() {
return { compare: argumentSpy };
@@ -195,14 +230,14 @@
});
env.expect(true).toBeReal();
- env.expect(true).toBeReal("arg");
- env.expect(true).toBeReal("arg1", "arg2");
+ env.expect(true).toBeReal('arg');
+ env.expect(true).toBeReal('arg1', 'arg2');
});
var specExpectations = function() {
expect(argumentSpy).toHaveBeenCalledWith(true);
- expect(argumentSpy).toHaveBeenCalledWith(true, "arg");
- expect(argumentSpy).toHaveBeenCalledWith(true, "arg1", "arg2");
+ expect(argumentSpy).toHaveBeenCalledWith(true, 'arg');
+ expect(argumentSpy).toHaveBeenCalledWith(true, 'arg1', 'arg2');
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
@@ -210,13 +245,22 @@
});
// TODO: remove this in the next major release.
- it("passes the jasmine utility and current equality testers to the matcher factory", function(done) {
- var matcherFactory = function() { return { compare: function() { return {pass: true}; }}; },
- matcherFactorySpy = jasmine.createSpy("matcherFactorySpy").and.callFake(matcherFactory),
- customEqualityFn = function() { return true; };
+ it('passes the jasmine utility and current equality testers to the matcher factory', function(done) {
+ var matcherFactory = function() {
+ return {
+ compare: function() {
+ return { pass: true };
+ }
+ };
+ },
+ matcherFactorySpy = jasmine
+ .createSpy('matcherFactorySpy')
+ .and.callFake(matcherFactory),
+ customEqualityFn = function() {
+ return true;
+ };
-
- env.it("spec with expectation", function() {
+ env.it('spec with expectation', function() {
env.addCustomEqualityTester(customEqualityFn);
env.addMatchers({
toBeReal: matcherFactorySpy
@@ -236,33 +280,35 @@
env.execute();
});
- it("provides custom equality testers to the matcher factory via matchersUtil", function (done) {
- var matcherFactory = function (matchersUtil) {
+ it('provides custom equality testers to the matcher factory via matchersUtil', function(done) {
+ var matcherFactory = function(matchersUtil) {
return {
- compare: function (actual, expected) {
- return {pass: matchersUtil.equals(actual[0], expected)};
+ compare: function(actual, expected) {
+ return { pass: matchersUtil.equals(actual[0], expected) };
}
};
},
- customEqualityFn = jasmine.createSpy("customEqualityFn").and.callFake(function (a, b) {
- return a.toString() === b;
- });
+ customEqualityFn = jasmine
+ .createSpy('customEqualityFn')
+ .and.callFake(function(a, b) {
+ return a.toString() === b;
+ });
- env.it("spec with expectation", function () {
+ env.it('spec with expectation', function() {
env.addCustomEqualityTester(customEqualityFn);
env.addMatchers({
toBeArrayWithFirstElement: matcherFactory
});
- env.expect([1, 2]).toBeArrayWithFirstElement("1");
+ env.expect([1, 2]).toBeArrayWithFirstElement('1');
});
- var specExpectations = function (result) {
- expect(customEqualityFn).toHaveBeenCalledWith(1, "1");
+ var specExpectations = function(result) {
+ expect(customEqualityFn).toHaveBeenCalledWith(1, '1');
expect(result.failedExpectations).toEqual([]);
};
- env.addReporter({specDone: specExpectations, jasmineDone: done});
+ env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
});
diff --git a/spec/core/integration/CustomObjectFormatterSpec.js b/spec/core/integration/CustomObjectFormatterSpec.js
index 10ed4d7..111edef 100644
--- a/spec/core/integration/CustomObjectFormatterSpec.js
+++ b/spec/core/integration/CustomObjectFormatterSpec.js
@@ -1,14 +1,16 @@
-describe("Custom object formatters", function() {
+describe('Custom object formatters', function() {
var env;
beforeEach(function() {
env = new jasmineUnderTest.Env();
- env.configure({random: false});
+ env.configure({ random: false });
});
- it("scopes custom object formatters to a spec", function(done) {
+ it('scopes custom object formatters to a spec', function(done) {
env.it('a spec with custom pretty-printer', function() {
- env.addCustomObjectFormatter(function(obj) { return 'custom(' + obj + ')'; });
+ env.addCustomObjectFormatter(function(obj) {
+ return 'custom(' + obj + ')';
+ });
env.expect(42).toBeUndefined();
});
@@ -21,23 +23,29 @@
specResults.push(result);
};
var expectations = function() {
- expect(specResults[0].failedExpectations[0].message).toEqual("Expected custom(42) to be undefined.");
- expect(specResults[1].failedExpectations[0].message).toEqual("Expected 42 to be undefined.");
+ expect(specResults[0].failedExpectations[0].message).toEqual(
+ 'Expected custom(42) to be undefined.'
+ );
+ expect(specResults[1].failedExpectations[0].message).toEqual(
+ 'Expected 42 to be undefined.'
+ );
done();
};
- env.addReporter({ specDone:specDone, jasmineDone: expectations});
+ env.addReporter({ specDone: specDone, jasmineDone: expectations });
env.execute();
});
- it("scopes custom object formatters to a suite", function(done) {
+ it('scopes custom object formatters to a suite', function(done) {
env.it('a spec without custom pretty-printer', function() {
env.expect(42).toBeUndefined();
});
env.describe('with custom pretty-printer', function() {
env.beforeEach(function() {
- env.addCustomObjectFormatter(function(obj) { return 'custom(' + obj + ')'; });
+ env.addCustomObjectFormatter(function(obj) {
+ return 'custom(' + obj + ')';
+ });
});
env.it('a spec', function() {
@@ -50,18 +58,24 @@
specResults.push(result);
};
var expectations = function() {
- expect(specResults[0].failedExpectations[0].message).toEqual("Expected 42 to be undefined.");
- expect(specResults[1].failedExpectations[0].message).toEqual("Expected custom(42) to be undefined.");
+ expect(specResults[0].failedExpectations[0].message).toEqual(
+ 'Expected 42 to be undefined.'
+ );
+ expect(specResults[1].failedExpectations[0].message).toEqual(
+ 'Expected custom(42) to be undefined.'
+ );
done();
};
- env.addReporter({ specDone:specDone, jasmineDone: expectations});
+ env.addReporter({ specDone: specDone, jasmineDone: expectations });
env.execute();
});
- it("throws an exception if you try to add a custom object formatter outside a runable", function() {
+ it('throws an exception if you try to add a custom object formatter outside a runable', function() {
expect(function() {
env.addCustomObjectFormatter(function() {});
- }).toThrowError('Custom object formatters must be added in a before function or a spec')
+ }).toThrowError(
+ 'Custom object formatters must be added in a before function or a spec'
+ );
});
});
diff --git a/spec/core/integration/CustomSpyStrategiesSpec.js b/spec/core/integration/CustomSpyStrategiesSpec.js
index 7ab4d28..c273dee 100644
--- a/spec/core/integration/CustomSpyStrategiesSpec.js
+++ b/spec/core/integration/CustomSpyStrategiesSpec.js
@@ -3,7 +3,7 @@
beforeEach(function() {
env = new jasmineUnderTest.Env();
- env.configure({random: false});
+ env.configure({ random: false });
});
afterEach(function() {
@@ -11,10 +11,8 @@
});
it('allows adding more strategies local to a suite', function(done) {
- var plan = jasmine.createSpy('custom strategy plan')
- .and.returnValue(42);
- var strategy = jasmine.createSpy('custom strategy')
- .and.returnValue(plan);
+ var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42);
+ var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan);
env.describe('suite defining a custom spy strategy', function() {
env.beforeEach(function() {
@@ -43,10 +41,8 @@
});
it('allows adding more strategies local to a spec', function(done) {
- var plan = jasmine.createSpy('custom strategy plan')
- .and.returnValue(42);
- var strategy = jasmine.createSpy('custom strategy')
- .and.returnValue(plan);
+ var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42);
+ var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan);
env.it('spec defining a custom spy strategy', function() {
env.addSpyStrategy('frobnicate', strategy);
@@ -70,16 +66,16 @@
});
it('allows using custom strategies on a per-argument basis', function(done) {
- var plan = jasmine.createSpy('custom strategy plan')
- .and.returnValue(42);
- var strategy = jasmine.createSpy('custom strategy')
- .and.returnValue(plan);
+ var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42);
+ var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan);
env.it('spec defining a custom spy strategy', function() {
env.addSpyStrategy('frobnicate', strategy);
- var spy = env.createSpy('something')
+ var spy = env
+ .createSpy('something')
.and.returnValue('no args return')
- .withArgs(1, 2, 3).and.frobnicate(17);
+ .withArgs(1, 2, 3)
+ .and.frobnicate(17);
expect(spy()).toEqual('no args return');
expect(plan).not.toHaveBeenCalled();
diff --git a/spec/core/integration/DefaultSpyStrategySpec.js b/spec/core/integration/DefaultSpyStrategySpec.js
index 584b25b..5d929b4 100644
--- a/spec/core/integration/DefaultSpyStrategySpec.js
+++ b/spec/core/integration/DefaultSpyStrategySpec.js
@@ -3,7 +3,7 @@
beforeEach(function() {
env = new jasmineUnderTest.Env();
- env.configure({random: false});
+ env.configure({ random: false });
});
afterEach(function() {
@@ -13,7 +13,7 @@
it('allows defining a default spy strategy', function(done) {
env.describe('suite with default strategy', function() {
env.beforeEach(function() {
- env.setDefaultSpyStrategy(function (and) {
+ env.setDefaultSpyStrategy(function(and) {
and.returnValue(42);
});
});
@@ -38,12 +38,16 @@
env.execute();
});
- it('uses the default spy strategy defined when the spy is created', function (done) {
+ it('uses the default spy strategy defined when the spy is created', function(done) {
env.it('spec', function() {
var a = env.createSpy('a');
- env.setDefaultSpyStrategy(function (and) { and.returnValue(42); });
+ env.setDefaultSpyStrategy(function(and) {
+ and.returnValue(42);
+ });
var b = env.createSpy('b');
- env.setDefaultSpyStrategy(function (and) { and.stub(); });
+ env.setDefaultSpyStrategy(function(and) {
+ and.stub();
+ });
var c = env.createSpy('c');
env.setDefaultSpyStrategy();
var d = env.createSpy('d');
diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js
index 090bb54..e9c7aa2 100644
--- a/spec/core/integration/EnvSpec.js
+++ b/spec/core/integration/EnvSpec.js
@@ -1,4 +1,4 @@
-describe("Env integration", function() {
+describe('Env integration', function() {
var env;
beforeEach(function() {
@@ -10,34 +10,31 @@
env.cleanup_();
});
- it("Suites execute as expected (no nesting)", function(done) {
+ it('Suites execute as expected (no nesting)', function(done) {
var calls = [];
var assertions = function() {
- expect(calls).toEqual([
- "with a spec",
- "and another spec"
- ]);
+ expect(calls).toEqual(['with a spec', 'and another spec']);
done();
};
- env.addReporter({ jasmineDone: assertions});
- env.configure({random: false});
+ env.addReporter({ jasmineDone: assertions });
+ env.configure({ random: false });
- env.describe("A Suite", function() {
- env.it("with a spec", function() {
- calls.push("with a spec");
+ env.describe('A Suite', function() {
+ env.it('with a spec', function() {
+ calls.push('with a spec');
});
- env.it("and another spec", function() {
- calls.push("and another spec");
+ env.it('and another spec', function() {
+ calls.push('and another spec');
});
});
env.execute();
});
- it("Nested Suites execute as expected", function(done) {
+ it('Nested Suites execute as expected', function(done) {
var calls = [];
var assertions = function() {
@@ -51,17 +48,17 @@
};
env.addReporter({ jasmineDone: assertions });
- env.configure({random: false});
+ env.configure({ random: false });
- env.describe("Outer suite", function() {
- env.it("an outer spec", function() {
- calls.push('an outer spec')
+ env.describe('Outer suite', function() {
+ env.it('an outer spec', function() {
+ calls.push('an outer spec');
});
- env.describe("Inner suite", function() {
- env.it("an inner spec", function() {
+ env.describe('Inner suite', function() {
+ env.it('an inner spec', function() {
calls.push('an inner spec');
});
- env.it("another inner spec", function() {
+ env.it('another inner spec', function() {
calls.push('another inner spec');
});
});
@@ -70,7 +67,7 @@
env.execute();
});
- it("Multiple top-level Suites execute as expected", function(done) {
+ it('Multiple top-level Suites execute as expected', function(done) {
var calls = [];
var assertions = function() {
@@ -85,26 +82,25 @@
};
env.addReporter({ jasmineDone: assertions });
- env.configure({random: false});
+ env.configure({ random: false });
-
- env.describe("Outer suite", function() {
- env.it("an outer spec", function() {
+ env.describe('Outer suite', function() {
+ env.it('an outer spec', function() {
calls.push('an outer spec');
});
- env.describe("Inner suite", function() {
- env.it("an inner spec", function() {
+ env.describe('Inner suite', function() {
+ env.it('an inner spec', function() {
calls.push('an inner spec');
});
- env.it("another inner spec", function() {
+ env.it('another inner spec', function() {
calls.push('another inner spec');
});
});
});
- env.describe("Another outer suite", function() {
- env.it("a 2nd outer spec", function() {
- calls.push('a 2nd outer spec')
+ env.describe('Another outer suite', function() {
+ env.it('a 2nd outer spec', function() {
+ calls.push('a 2nd outer spec');
});
});
@@ -117,45 +113,62 @@
env.addReporter({
specDone: specDone,
jasmineDone: function() {
- expect(specDone).toHaveBeenCalledWith(jasmine.objectContaining({
- description: 'has a default message',
- failedExpectations: [jasmine.objectContaining({
- message: 'Failed'
- })]
- }));
- expect(specDone).toHaveBeenCalledWith(jasmine.objectContaining({
- description: 'specifies a message',
- failedExpectations: [jasmine.objectContaining({
- message: 'Failed: messy message'
- })]
- }));
- expect(specDone).toHaveBeenCalledWith(jasmine.objectContaining({
- description: 'has a message and stack trace from an Error',
- failedExpectations: [jasmine.objectContaining({
- message: 'Failed: error message',
- stack: {
- asymmetricMatch: function(other) {
- if (!other) {
- // IE doesn't give us a stacktrace so just ignore it.
- return true;
+ expect(specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ description: 'has a default message',
+ failedExpectations: [
+ jasmine.objectContaining({
+ message: 'Failed'
+ })
+ ]
+ })
+ );
+ expect(specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ description: 'specifies a message',
+ failedExpectations: [
+ jasmine.objectContaining({
+ message: 'Failed: messy message'
+ })
+ ]
+ })
+ );
+ expect(specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ description: 'has a message and stack trace from an Error',
+ failedExpectations: [
+ jasmine.objectContaining({
+ message: 'Failed: error message',
+ stack: {
+ asymmetricMatch: function(other) {
+ if (!other) {
+ // IE doesn't give us a stacktrace so just ignore it.
+ return true;
+ }
+ var split = other.split('\n'),
+ firstLine = split[0];
+ if (firstLine.indexOf('error message') >= 0) {
+ // Chrome inserts the message and a newline before the first stacktrace line.
+ firstLine = split[1];
+ }
+ return firstLine.indexOf('EnvSpec') >= 0;
+ }
}
- var split = other.split('\n'),
- firstLine = split[0];
- if (firstLine.indexOf('error message') >= 0) {
- // Chrome inserts the message and a newline before the first stacktrace line.
- firstLine = split[1];
- }
- return firstLine.indexOf('EnvSpec') >= 0;
- }
- }
- })]
- }));
- expect(specDone).toHaveBeenCalledWith(jasmine.objectContaining({
- description: 'pretty prints objects',
- failedExpectations: [jasmine.objectContaining({
- message: 'Failed: Object({ prop: \'value\', arr: [ \'works\', true ] })'
- })]
- }));
+ })
+ ]
+ })
+ );
+ expect(specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ description: 'pretty prints objects',
+ failedExpectations: [
+ jasmine.objectContaining({
+ message:
+ "Failed: Object({ prop: 'value', arr: [ 'works', true ] })"
+ })
+ ]
+ })
+ );
done();
}
});
@@ -174,8 +187,8 @@
});
env.it('pretty prints objects', function() {
- env.fail({prop: 'value', arr: ['works', true]});
- })
+ env.fail({ prop: 'value', arr: ['works', true] });
+ });
});
env.execute();
@@ -187,22 +200,27 @@
reporter.jasmineDone.and.callFake(done);
env.addReporter(reporter);
- env.describe("A Suite", function() {
- env.it("an async spec that is actually synchronous", function(underTestCallback) {
+ env.describe('A Suite', function() {
+ env.it('an async spec that is actually synchronous', function(
+ underTestCallback
+ ) {
underTestCallback();
});
- expect(function() { env.fail(); }).toThrowError(/'fail' was used when there was no current spec/);
+ expect(function() {
+ env.fail();
+ }).toThrowError(/'fail' was used when there was no current spec/);
});
env.execute();
});
-
it("calls associated befores/specs/afters with the same 'this'", function(done) {
- env.addReporter({jasmineDone: done});
- env.configure({random: false});
- env.describe("tests", function() {
- var firstTimeThrough = true, firstSpecContext, secondSpecContext;
+ env.addReporter({ jasmineDone: done });
+ env.configure({ random: false });
+ env.describe('tests', function() {
+ var firstTimeThrough = true,
+ firstSpecContext,
+ secondSpecContext;
env.beforeEach(function() {
if (firstTimeThrough) {
@@ -213,11 +231,11 @@
expect(this).toEqual(new jasmineUnderTest.UserContext());
});
- env.it("sync spec", function() {
+ env.it('sync spec', function() {
expect(this).toBe(firstSpecContext);
});
- env.it("another sync spec", function() {
+ env.it('another sync spec', function() {
expect(this).toBe(secondSpecContext);
});
@@ -235,9 +253,9 @@
});
it("calls associated befores/its/afters with the same 'this' for an async spec", function(done) {
- env.addReporter({jasmineDone: done});
+ env.addReporter({ jasmineDone: done });
- env.describe("with an async spec", function() {
+ env.describe('with an async spec', function() {
var specContext;
env.beforeEach(function() {
@@ -245,7 +263,7 @@
expect(this).toEqual(new jasmineUnderTest.UserContext());
});
- env.it("sync spec", function(underTestCallback) {
+ env.it('sync spec', function(underTestCallback) {
expect(this).toBe(specContext);
underTestCallback();
});
@@ -258,9 +276,9 @@
env.execute();
});
- it("calls associated beforeAlls/afterAlls only once per suite", function(done) {
+ it('calls associated beforeAlls/afterAlls only once per suite', function(done) {
var before = jasmine.createSpy('beforeAll'),
- after = jasmine.createSpy('afterAll');
+ after = jasmine.createSpy('afterAll');
env.addReporter({
jasmineDone: function() {
@@ -271,13 +289,13 @@
}
});
- env.describe("with beforeAll and afterAll", function() {
- env.it("spec", function() {
+ env.describe('with beforeAll and afterAll', function() {
+ env.it('spec', function() {
expect(before).toHaveBeenCalled();
expect(after).not.toHaveBeenCalled();
});
- env.it("another spec", function() {
+ env.it('another spec', function() {
expect(before).toHaveBeenCalled();
expect(after).not.toHaveBeenCalled();
});
@@ -289,9 +307,9 @@
env.execute();
});
- it("calls associated beforeAlls/afterAlls only once per suite for async", function(done) {
+ it('calls associated beforeAlls/afterAlls only once per suite for async', function(done) {
var before = jasmine.createSpy('beforeAll'),
- after = jasmine.createSpy('afterAll');
+ after = jasmine.createSpy('afterAll');
env.addReporter({
jasmineDone: function() {
@@ -302,13 +320,13 @@
}
});
- env.describe("with beforeAll and afterAll", function() {
- env.it("spec", function() {
+ env.describe('with beforeAll and afterAll', function() {
+ env.it('spec', function() {
expect(before).toHaveBeenCalled();
expect(after).not.toHaveBeenCalled();
});
- env.it("another spec", function() {
+ env.it('another spec', function() {
expect(before).toHaveBeenCalled();
expect(after).not.toHaveBeenCalled();
});
@@ -328,44 +346,44 @@
});
it("calls associated beforeAlls/afterAlls with the cascaded 'this'", function(done) {
- env.addReporter({jasmineDone: done});
+ env.addReporter({ jasmineDone: done });
- env.describe("with beforeAll and afterAll", function() {
+ env.describe('with beforeAll and afterAll', function() {
env.beforeAll(function() {
this.x = 1;
});
- env.it("has an x at the root", function() {
+ env.it('has an x at the root', function() {
expect(this.x).toBe(1);
});
- env.describe("child that deletes", function() {
+ env.describe('child that deletes', function() {
env.beforeAll(function() {
expect(this.x).toBe(1);
delete this.x;
});
- env.it("has no x", function() {
+ env.it('has no x', function() {
expect(this.x).not.toBeDefined();
});
});
- env.describe("child should still have x", function() {
+ env.describe('child should still have x', function() {
env.beforeAll(function(innerDone) {
expect(this.x).toBe(1);
innerDone();
});
- env.it("has an x", function() {
+ env.it('has an x', function() {
expect(this.x).toBe(1);
delete this.x;
});
- env.it("still has an x", function() {
+ env.it('still has an x', function() {
expect(this.x).toBe(1);
});
- env.it("adds a y", function() {
+ env.it('adds a y', function() {
this.y = 2;
expect(this.y).toBe(2);
});
@@ -379,11 +397,15 @@
env.execute();
});
- it("tags top-level afterAll failures with a type", function(done) {
- env.addReporter({jasmineDone: function(result) {
- expect(result.failedExpectations[0].globalErrorType).toEqual('afterAll');
- done();
- }});
+ it('tags top-level afterAll failures with a type', function(done) {
+ env.addReporter({
+ jasmineDone: function(result) {
+ expect(result.failedExpectations[0].globalErrorType).toEqual(
+ 'afterAll'
+ );
+ done();
+ }
+ });
env.it('has a spec', function() {});
@@ -394,16 +416,16 @@
env.execute();
});
- it("does not tag suite afterAll failures with a type", function(done) {
+ it('does not tag suite afterAll failures with a type', function(done) {
var reporter = {
- jasmineDone: function() {
- expect(reporter.suiteDone).toHaveBeenCalled();
- done();
- },
- suiteDone: jasmine.createSpy('suiteDone').and.callFake(function(result) {
- expect(result.failedExpectations[0].globalErrorType).toBeFalsy();
- })
- };
+ jasmineDone: function() {
+ expect(reporter.suiteDone).toHaveBeenCalled();
+ done();
+ },
+ suiteDone: jasmine.createSpy('suiteDone').and.callFake(function(result) {
+ expect(result.failedExpectations[0].globalErrorType).toBeFalsy();
+ })
+ };
env.addReporter(reporter);
@@ -418,50 +440,75 @@
env.execute();
});
- it("when the beforeAll fails, error at suite level", function (done) {
- var reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "suiteDone", "jasmineDone" ]);
+ it('when the beforeAll fails, error at suite level', function(done) {
+ var reporter = jasmine.createSpyObj('fakeReporter', [
+ 'specDone',
+ 'suiteDone',
+ 'jasmineDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
expect(reporter.specDone.calls.count()).toEqual(2);
- expect(reporter.specDone).toHaveFailedExpectationsForRunnable('A suite spec that will pass', []);
- expect(reporter.specDone).toHaveFailedExpectationsForRunnable('A suite nesting another spec to pass', []);
- expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('A suite', ['Expected 1 to be 2.']);
+ expect(reporter.specDone).toHaveFailedExpectationsForRunnable(
+ 'A suite spec that will pass',
+ []
+ );
+ expect(reporter.specDone).toHaveFailedExpectationsForRunnable(
+ 'A suite nesting another spec to pass',
+ []
+ );
+ expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
+ 'A suite',
+ ['Expected 1 to be 2.']
+ );
done();
});
env.addReporter(reporter);
- env.describe('A suite', function(){
+ env.describe('A suite', function() {
env.beforeAll(function() {
env.expect(1).toBe(2);
});
- env.it("spec that will pass", function() {
- });
+ env.it('spec that will pass', function() {});
- env.describe("nesting", function() {
- env.it("another spec to pass", function() {
- });
+ env.describe('nesting', function() {
+ env.it('another spec to pass', function() {});
});
});
env.execute();
});
- it("copes with async failures after done has been called", function(done) {
+ it('copes with async failures after done has been called', function(done) {
var global = {
- setTimeout: function(fn, delay) { setTimeout(fn, delay) },
- clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
+ setTimeout: function(fn, delay) {
+ setTimeout(fn, delay);
+ },
+ clearTimeout: function(fn, delay) {
+ clearTimeout(fn, delay);
+ }
};
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
env.cleanup_();
env = new jasmineUnderTest.Env();
- var reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone", "suiteDone" ]);
+ var reporter = jasmine.createSpyObj('fakeReporter', [
+ 'specDone',
+ 'jasmineDone',
+ 'suiteDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
- expect(reporter.specDone).not.toHaveFailedExpectationsForRunnable('A suite fails', ['fail thrown']);
- expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('A suite', ['fail thrown']);
+ expect(reporter.specDone).not.toHaveFailedExpectationsForRunnable(
+ 'A suite fails',
+ ['fail thrown']
+ );
+ expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
+ 'A suite',
+ ['fail thrown']
+ );
done();
});
@@ -472,9 +519,9 @@
setTimeout(function() {
specDone();
setTimeout(function() {
- setTimeout(function() {
- global.onerror('fail');
- });
+ setTimeout(function() {
+ global.onerror('fail');
+ });
});
});
});
@@ -487,23 +534,25 @@
env.execute();
});
- describe('suiteDone reporting', function(){
- it("reports when an afterAll fails an expectation", function(done) {
- var reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
+ describe('suiteDone reporting', function() {
+ it('reports when an afterAll fails an expectation', function(done) {
+ var reporter = jasmine.createSpyObj('fakeReport', [
+ 'jasmineDone',
+ 'suiteDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
- expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('my suite', [
- 'Expected 1 to equal 2.',
- 'Expected 2 to equal 3.'
- ]);
+ expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
+ 'my suite',
+ ['Expected 1 to equal 2.', 'Expected 2 to equal 3.']
+ );
done();
});
env.addReporter(reporter);
env.describe('my suite', function() {
- env.it('my spec', function() {
- });
+ env.it('my spec', function() {});
env.afterAll(function() {
env.expect(1).toEqual(2);
@@ -514,14 +563,17 @@
env.execute();
});
- it("if there are no specs, it still reports correctly", function(done) {
- var reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
+ it('if there are no specs, it still reports correctly', function(done) {
+ var reporter = jasmine.createSpyObj('fakeReport', [
+ 'jasmineDone',
+ 'suiteDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
- expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('outer suite', [
- 'Expected 1 to equal 2.',
- 'Expected 2 to equal 3.'
- ]);
+ expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
+ 'outer suite',
+ ['Expected 1 to equal 2.', 'Expected 2 to equal 3.']
+ );
done();
});
@@ -529,7 +581,7 @@
env.describe('outer suite', function() {
env.describe('inner suite', function() {
- env.it('spec', function(){ });
+ env.it('spec', function() {});
});
env.afterAll(function() {
@@ -541,22 +593,25 @@
env.execute();
});
- it("reports when afterAll throws an exception", function(done) {
+ it('reports when afterAll throws an exception', function(done) {
var error = new Error('After All Exception'),
- reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
+ reporter = jasmine.createSpyObj('fakeReport', [
+ 'jasmineDone',
+ 'suiteDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
- expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('my suite', [
- (/^Error: After All Exception/)
- ]);
+ expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
+ 'my suite',
+ [/^Error: After All Exception/]
+ );
done();
});
env.addReporter(reporter);
env.describe('my suite', function() {
- env.it('my spec', function() {
- });
+ env.it('my spec', function() {});
env.afterAll(function() {
throw error;
@@ -566,21 +621,24 @@
env.execute();
});
- it("reports when an async afterAll fails an expectation", function(done) {
- var reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
+ it('reports when an async afterAll fails an expectation', function(done) {
+ var reporter = jasmine.createSpyObj('fakeReport', [
+ 'jasmineDone',
+ 'suiteDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
- expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('my suite', [
- 'Expected 1 to equal 2.'
- ]);
+ expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
+ 'my suite',
+ ['Expected 1 to equal 2.']
+ );
done();
});
env.addReporter(reporter);
env.describe('my suite', function() {
- env.it('my spec', function() {
- });
+ env.it('my spec', function() {});
env.afterAll(function(afterAllDone) {
env.expect(1).toEqual(2);
@@ -591,23 +649,25 @@
env.execute();
});
- it("reports when an async afterAll throws an exception", function(done) {
+ it('reports when an async afterAll throws an exception', function(done) {
var error = new Error('After All Exception'),
- reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']);
-
+ reporter = jasmine.createSpyObj('fakeReport', [
+ 'jasmineDone',
+ 'suiteDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
- expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('my suite', [
- (/^Error: After All Exception/)
- ]);
+ expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
+ 'my suite',
+ [/^Error: After All Exception/]
+ );
done();
});
env.addReporter(reporter);
env.describe('my suite', function() {
- env.it('my spec', function() {
- });
+ env.it('my spec', function() {});
env.afterAll(function(afterAllDone) {
throw error;
@@ -636,7 +696,7 @@
// We can't just use the mock clock here because the timer is designed
// to record real time even when the mock clock is installed.
setTimeout(done, 10);
- })
+ });
});
env.execute();
@@ -663,7 +723,7 @@
// We can't just use the mock clock here because the timer is designed
// to record real time even when the mock clock is installed.
setTimeout(done, 10);
- })
+ });
});
env.execute();
@@ -674,8 +734,13 @@
var reporter = jasmine.createSpyObj(['specDone', 'jasmineDone']);
reporter.jasmineDone.and.callFake(function(results) {
- expect(results.failedExpectations).toEqual([jasmine.objectContaining({ message: 'Expected 1 to be 0.' })]);
- expect(reporter.specDone).toHaveFailedExpectationsForRunnable('is a spec', []);
+ expect(results.failedExpectations).toEqual([
+ jasmine.objectContaining({ message: 'Expected 1 to be 0.' })
+ ]);
+ expect(reporter.specDone).toHaveFailedExpectationsForRunnable(
+ 'is a spec',
+ []
+ );
done();
});
@@ -696,7 +761,9 @@
var reporter = jasmine.createSpyObj(['jasmineDone']);
reporter.jasmineDone.and.callFake(function(results) {
- expect(results.failedExpectations).toEqual([jasmine.objectContaining({ message: 'Expected 1 to be 0.' })]);
+ expect(results.failedExpectations).toEqual([
+ jasmine.objectContaining({ message: 'Expected 1 to be 0.' })
+ ]);
done();
});
@@ -713,34 +780,31 @@
env.execute();
});
- it("Allows specifying which specs and suites to run", function(done) {
+ it('Allows specifying which specs and suites to run', function(done) {
var calls = [],
- suiteCallback = jasmine.createSpy('suite callback'),
- firstSpec,
- secondSuite;
+ suiteCallback = jasmine.createSpy('suite callback'),
+ firstSpec,
+ secondSuite;
var assertions = function() {
- expect(calls).toEqual([
- 'third spec',
- 'first spec'
- ]);
+ expect(calls).toEqual(['third spec', 'first spec']);
expect(suiteCallback).toHaveBeenCalled();
done();
};
- env.addReporter({jasmineDone: assertions, suiteDone: suiteCallback});
+ env.addReporter({ jasmineDone: assertions, suiteDone: suiteCallback });
- env.describe("first suite", function() {
- firstSpec = env.it("first spec", function() {
+ env.describe('first suite', function() {
+ firstSpec = env.it('first spec', function() {
calls.push('first spec');
});
- env.it("second spec", function() {
+ env.it('second spec', function() {
calls.push('second spec');
});
});
- secondSuite = env.describe("second suite", function() {
- env.it("third spec", function() {
+ secondSuite = env.describe('second suite', function() {
+ env.it('third spec', function() {
calls.push('third spec');
});
});
@@ -754,64 +818,58 @@
second_spec;
var assertions = function() {
- expect(calls).toEqual([
- "before",
- "first spec",
- "second spec",
- "after"
- ]);
+ expect(calls).toEqual(['before', 'first spec', 'second spec', 'after']);
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
- env.describe("first suite", function() {
+ env.describe('first suite', function() {
env.beforeAll(function() {
- calls.push("before");
+ calls.push('before');
});
env.afterAll(function() {
- calls.push("after")
+ calls.push('after');
});
- first_spec = env.it("spec", function() {
+ first_spec = env.it('spec', function() {
calls.push('first spec');
});
- second_spec = env.it("spec 2", function() {
- calls.push("second spec");
+ second_spec = env.it('spec 2', function() {
+ calls.push('second spec');
});
});
env.execute([first_spec.id, second_spec.id]);
});
- it("Allows filtering out specs and suites to run programmatically", function(done) {
+ it('Allows filtering out specs and suites to run programmatically', function(done) {
var calls = [],
- suiteCallback = jasmine.createSpy('suite callback'),
- firstSpec,
- secondSuite;
+ suiteCallback = jasmine.createSpy('suite callback'),
+ firstSpec,
+ secondSuite;
var assertions = function() {
expect(calls.length).toEqual(2);
- expect(calls).toEqual(jasmine.arrayContaining([
- 'first spec',
- 'second spec'
- ]));
+ expect(calls).toEqual(
+ jasmine.arrayContaining(['first spec', 'second spec'])
+ );
expect(suiteCallback).toHaveBeenCalled();
done();
};
- env.addReporter({jasmineDone: assertions, suiteDone: suiteCallback});
+ env.addReporter({ jasmineDone: assertions, suiteDone: suiteCallback });
- env.describe("first suite", function() {
- env.it("first spec", function() {
+ env.describe('first suite', function() {
+ env.it('first spec', function() {
calls.push('first spec');
});
- env.it("second spec", function() {
+ env.it('second spec', function() {
calls.push('second spec');
});
});
- secondSuite = env.describe("second suite", function() {
- env.it("third spec", function() {
+ secondSuite = env.describe('second suite', function() {
+ env.it('third spec', function() {
calls.push('third spec');
});
});
@@ -825,19 +883,21 @@
env.execute();
});
- it("Functions can be spied on and have their calls tracked", function (done) {
+ it('Functions can be spied on and have their calls tracked', function(done) {
var originalFunctionWasCalled = false;
var subject = {
spiedFunc: function() {
originalFunctionWasCalled = true;
- return "original result";
+ return 'original result';
}
};
- env.addReporter({jasmineDone: done});
+ env.addReporter({ jasmineDone: done });
- env.it("works with spies", function() {
- var spy = env.spyOn(subject, 'spiedFunc').and.returnValue("stubbed result");
+ env.it('works with spies', function() {
+ var spy = env
+ .spyOn(subject, 'spiedFunc')
+ .and.returnValue('stubbed result');
expect(subject.spiedFunc).toEqual(spy);
expect(subject.spiedFunc.calls.any()).toEqual(false);
@@ -849,58 +909,72 @@
expect(subject.spiedFunc.calls.count()).toEqual(1);
expect(subject.spiedFunc.calls.mostRecent().args).toEqual(['foo']);
expect(subject.spiedFunc.calls.mostRecent().object).toEqual(subject);
- expect(subject.spiedFunc.calls.mostRecent().returnValue).toEqual("stubbed result");
+ expect(subject.spiedFunc.calls.mostRecent().returnValue).toEqual(
+ 'stubbed result'
+ );
expect(originalFunctionWasCalled).toEqual(false);
subject.spiedFunc.and.callThrough();
subject.spiedFunc('bar');
expect(subject.spiedFunc.calls.count()).toEqual(2);
expect(subject.spiedFunc.calls.mostRecent().args).toEqual(['bar']);
- expect(subject.spiedFunc.calls.mostRecent().returnValue).toEqual("original result");
+ expect(subject.spiedFunc.calls.mostRecent().returnValue).toEqual(
+ 'original result'
+ );
expect(originalFunctionWasCalled).toEqual(true);
});
- env.it("works with constructors when using callThrough spy strategy", function() {
- function MyClass(foo) {
- if (!(this instanceof MyClass)) throw new Error('You must use the new keyword.');
- this.foo = foo;
+ env.it(
+ 'works with constructors when using callThrough spy strategy',
+ function() {
+ function MyClass(foo) {
+ if (!(this instanceof MyClass))
+ throw new Error('You must use the new keyword.');
+ this.foo = foo;
+ }
+ var subject = { MyClass: MyClass };
+ var spy = env.spyOn(subject, 'MyClass').and.callThrough();
+
+ expect(function() {
+ var result = new spy('hello world');
+ expect(result instanceof MyClass).toBeTruthy();
+ expect(result.foo).toEqual('hello world');
+ }).not.toThrow();
+
+ expect(function() {
+ var result = new spy(
+ 'passing',
+ 'extra',
+ 'arguments',
+ 'to',
+ 'constructor'
+ );
+ expect(result instanceof MyClass).toBeTruthy();
+ expect(result.foo).toEqual('passing');
+ }).not.toThrow();
+
+ expect(function() {
+ spy('hello world');
+ }).toThrowError('You must use the new keyword.');
}
- var subject = { MyClass: MyClass };
- var spy = env.spyOn(subject, 'MyClass').and.callThrough();
-
- expect(function() {
- var result = new spy('hello world');
- expect(result instanceof MyClass).toBeTruthy();
- expect(result.foo).toEqual('hello world');
- }).not.toThrow();
-
- expect(function() {
- var result = new spy('passing', 'extra', 'arguments', 'to', 'constructor');
- expect(result instanceof MyClass).toBeTruthy();
- expect(result.foo).toEqual('passing');
- }).not.toThrow();
-
- expect(function() {
- spy('hello world');
- }).toThrowError('You must use the new keyword.');
- });
+ );
env.execute();
});
- it('can be configured to allow respying on functions', function (done) {
+ it('can be configured to allow respying on functions', function(done) {
var foo = {
- bar: function () {
- return 1;
- }
- };
+ bar: function() {
+ return 1;
+ }
+ };
env.allowRespy(true);
env.addReporter({ jasmineDone: done });
env.describe('test suite', function() {
env.it('spec 0', function() {
- env.spyOn(foo,'bar');
+ env.spyOn(foo, 'bar');
var error = null;
@@ -924,10 +998,10 @@
secondSpec = jasmine.createSpy('secondSpec').and.callFake(function() {
expect(testObj.foo).toBe(originalFoo);
});
- env.describe('test suite', function() {
- env.it('spec 0', firstSpec);
- env.it('spec 1', secondSpec);
- });
+ env.describe('test suite', function() {
+ env.it('spec 0', firstSpec);
+ env.it('spec 1', secondSpec);
+ });
var assertions = function() {
expect(firstSpec).toHaveBeenCalled();
@@ -946,24 +1020,26 @@
foo: originalFoo
};
- env.describe('test suite', function() {
- env.beforeAll(function() { env.spyOn(testObj, 'foo');});
-
- env.it('spec 0', function() {
- expect(jasmineUnderTest.isSpy(testObj.foo)).toBe(true);
- });
-
- env.it('spec 1', function() {
- expect(jasmineUnderTest.isSpy(testObj.foo)).toBe(true);
- });
+ env.describe('test suite', function() {
+ env.beforeAll(function() {
+ env.spyOn(testObj, 'foo');
});
- env.describe('another suite', function() {
- env.it('spec 2', function() {
- expect(jasmineUnderTest.isSpy(testObj.foo)).toBe(false);
- });
+ env.it('spec 0', function() {
+ expect(jasmineUnderTest.isSpy(testObj.foo)).toBe(true);
});
+ env.it('spec 1', function() {
+ expect(jasmineUnderTest.isSpy(testObj.foo)).toBe(true);
+ });
+ });
+
+ env.describe('another suite', function() {
+ env.it('spec 2', function() {
+ expect(jasmineUnderTest.isSpy(testObj.foo)).toBe(false);
+ });
+ });
+
env.addReporter({ jasmineDone: done });
env.execute();
@@ -993,32 +1069,51 @@
env.execute();
});
- it("Mock clock can be installed and used in tests", function(done) {
- var globalSetTimeout = jasmine.createSpy('globalSetTimeout').and.callFake(function(cb, t) { setTimeout(cb, t); }),
- delayedFunctionForGlobalClock = jasmine.createSpy('delayedFunctionForGlobalClock'),
- delayedFunctionForMockClock = jasmine.createSpy('delayedFunctionForMockClock');
+ it('Mock clock can be installed and used in tests', function(done) {
+ var globalSetTimeout = jasmine
+ .createSpy('globalSetTimeout')
+ .and.callFake(function(cb, t) {
+ setTimeout(cb, t);
+ }),
+ delayedFunctionForGlobalClock = jasmine.createSpy(
+ 'delayedFunctionForGlobalClock'
+ ),
+ delayedFunctionForMockClock = jasmine.createSpy(
+ 'delayedFunctionForMockClock'
+ );
env.cleanup_();
- env = new jasmineUnderTest.Env({global: { setTimeout: globalSetTimeout, clearTimeout: clearTimeout, setImmediate: function(cb) { setTimeout(cb, 0); } }});
+ env = new jasmineUnderTest.Env({
+ global: {
+ setTimeout: globalSetTimeout,
+ clearTimeout: clearTimeout,
+ setImmediate: function(cb) {
+ setTimeout(cb, 0);
+ }
+ }
+ });
var assertions = function() {
expect(delayedFunctionForMockClock).toHaveBeenCalled();
- expect(globalSetTimeout).toHaveBeenCalledWith(delayedFunctionForGlobalClock, 100);
+ expect(globalSetTimeout).toHaveBeenCalledWith(
+ delayedFunctionForGlobalClock,
+ 100
+ );
done();
};
env.addReporter({ jasmineDone: assertions });
- env.configure({random: false});
+ env.configure({ random: false });
- env.describe("tests", function() {
- env.it("test with mock clock", function() {
+ env.describe('tests', function() {
+ env.it('test with mock clock', function() {
env.clock.install();
env.clock.setTimeout(delayedFunctionForMockClock, 100);
env.clock.tick(100);
env.clock.uninstall();
});
- env.it("test without mock clock", function() {
+ env.it('test without mock clock', function() {
env.clock.setTimeout(delayedFunctionForGlobalClock, 100);
});
});
@@ -1029,28 +1124,28 @@
env.execute();
});
- it("should run async specs in order, waiting for them to complete", function(done) {
+ it('should run async specs in order, waiting for them to complete', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['jasmineDone']),
- mutatedVar;
+ mutatedVar;
reporter.jasmineDone.and.callFake(function() {
done();
});
env.addReporter(reporter);
- env.describe("tests", function() {
+ env.describe('tests', function() {
env.beforeEach(function() {
mutatedVar = 2;
});
- env.it("async spec", function(underTestCallback) {
+ env.it('async spec', function(underTestCallback) {
setTimeout(function() {
expect(mutatedVar).toEqual(2);
underTestCallback();
}, 0);
});
- env.it("after async spec", function() {
+ env.it('after async spec', function() {
mutatedVar = 3;
});
});
@@ -1058,13 +1153,14 @@
env.execute();
});
- describe("with a mock clock", function() {
+ describe('with a mock clock', function() {
var realSetTimeout;
function createMockedEnv() {
env.cleanup_();
// explicitly pass in timing functions so we can make sure that clear stack always works
// no matter how long the suite in the spec is
- env = new jasmineUnderTest.Env({ global: {
+ env = new jasmineUnderTest.Env({
+ global: {
setTimeout: function(cb, t) {
var stack = jasmine.util.errorWithStack().stack;
if (stack.indexOf('ClearStack') >= 0) {
@@ -1076,8 +1172,11 @@
clearTimeout: clearTimeout,
setInterval: setInterval,
clearInterval: clearInterval,
- setImmediate: function(cb) { realSetTimeout(cb, 0); }
- }});
+ setImmediate: function(cb) {
+ realSetTimeout(cb, 0);
+ }
+ }
+ });
}
beforeEach(function() {
@@ -1095,10 +1194,13 @@
it("should wait a default interval before failing specs that haven't called done yet", function(done) {
createMockedEnv();
- var reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]);
+ var reporter = jasmine.createSpyObj('fakeReporter', [
+ 'specDone',
+ 'jasmineDone'
+ ]);
reporter.specDone.and.callFake(function(result) {
- expect(result).toEqual(jasmine.objectContaining({status: 'failed'}));
+ expect(result).toEqual(jasmine.objectContaining({ status: 'failed' }));
realSetTimeout(function() {
jasmine.clock().tick(1);
}, 0);
@@ -1122,9 +1224,12 @@
env.execute();
});
- it("should not use the mock clock for asynchronous timeouts", function(done){
+ it('should not use the mock clock for asynchronous timeouts', function(done) {
createMockedEnv();
- var reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]),
+ var reporter = jasmine.createSpyObj('fakeReporter', [
+ 'specDone',
+ 'jasmineDone'
+ ]),
clock = env.clock;
reporter.specDone.and.callFake(function() {
@@ -1135,7 +1240,9 @@
reporter.jasmineDone.and.callFake(function() {
expect(reporter.specDone).toHaveBeenCalledTimes(1);
- expect(reporter.specDone.calls.argsFor(0)[0]).toEqual(jasmine.objectContaining({status: 'passed'}));
+ expect(reporter.specDone.calls.argsFor(0)[0]).toEqual(
+ jasmine.objectContaining({ status: 'passed' })
+ );
jasmine.clock().tick(1);
realSetTimeout(done);
});
@@ -1151,7 +1258,7 @@
clock.uninstall();
});
- env.it("spec that should not time out", function(innerDone) {
+ env.it('spec that should not time out', function(innerDone) {
clock.tick(6);
expect(true).toEqual(true);
realSetTimeout(innerDone);
@@ -1162,15 +1269,44 @@
it('should wait a custom interval before reporting async functions that fail to complete', function(done) {
createMockedEnv();
- var reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone', 'suiteDone', 'specDone']);
+ var reporter = jasmine.createSpyObj('fakeReport', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function(r) {
expect(r.failedExpectations).toEqual([]);
- expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('suite beforeAll', [ /^Error: Timeout - Async function did not complete within 5000ms \(custom timeout\)/ ]);
- expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('suite afterAll', [ /^Error: Timeout - Async function did not complete within 2000ms \(custom timeout\)/ ]);
- expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite beforeEach times out', [/^Error: Timeout - Async function did not complete within 1000ms \(custom timeout\)/]);
- expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite afterEach times out', [ /^Error: Timeout - Async function did not complete within 4000ms \(custom timeout\)/ ]);
- expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite it times out', [ /^Error: Timeout - Async function did not complete within 6000ms \(custom timeout\)/ ]);
+ expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
+ 'suite beforeAll',
+ [
+ /^Error: Timeout - Async function did not complete within 5000ms \(custom timeout\)/
+ ]
+ );
+ expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
+ 'suite afterAll',
+ [
+ /^Error: Timeout - Async function did not complete within 2000ms \(custom timeout\)/
+ ]
+ );
+ expect(reporter.specDone).toHaveFailedExpectationsForRunnable(
+ 'suite beforeEach times out',
+ [
+ /^Error: Timeout - Async function did not complete within 1000ms \(custom timeout\)/
+ ]
+ );
+ expect(reporter.specDone).toHaveFailedExpectationsForRunnable(
+ 'suite afterEach times out',
+ [
+ /^Error: Timeout - Async function did not complete within 4000ms \(custom timeout\)/
+ ]
+ );
+ expect(reporter.specDone).toHaveFailedExpectationsForRunnable(
+ 'suite it times out',
+ [
+ /^Error: Timeout - Async function did not complete within 6000ms \(custom timeout\)/
+ ]
+ );
jasmine.clock().tick(1);
realSetTimeout(done);
@@ -1184,7 +1320,7 @@
realSetTimeout(function() {
try {
jasmine.clock().tick(10);
- } catch(e) {
+ } catch (e) {
// don't worry if the clock is already uninstalled
}
}, 100);
@@ -1249,11 +1385,15 @@
});
});
- env.it('it times out', function(innerDone) {
- realSetTimeout(function() {
- jasmine.clock().tick(6001);
- }, 0);
- }, 6000);
+ env.it(
+ 'it times out',
+ function(innerDone) {
+ realSetTimeout(function() {
+ jasmine.clock().tick(6001);
+ }, 0);
+ },
+ 6000
+ );
});
env.execute();
@@ -1266,19 +1406,24 @@
env.addReporter({
specDone: specDone,
jasmineDone: function() {
- expect(specDone).toHaveFailedExpectationsForRunnable('failing has a default message',
+ expect(specDone).toHaveFailedExpectationsForRunnable(
+ 'failing has a default message',
['Failed']
);
- expect(specDone).toHaveFailedExpectationsForRunnable('failing specifies a message',
+ expect(specDone).toHaveFailedExpectationsForRunnable(
+ 'failing specifies a message',
['Failed: messy message']
);
- expect(specDone).toHaveFailedExpectationsForRunnable('failing fails via the done callback',
+ expect(specDone).toHaveFailedExpectationsForRunnable(
+ 'failing fails via the done callback',
['Failed: done failed']
);
- expect(specDone).toHaveFailedExpectationsForRunnable('failing has a message from an Error',
+ expect(specDone).toHaveFailedExpectationsForRunnable(
+ 'failing has a message from an Error',
['Failed: error message']
);
- expect(specDone).toHaveFailedExpectationsForRunnable('failing has a message from an Error to done',
+ expect(specDone).toHaveFailedExpectationsForRunnable(
+ 'failing has a message from an Error to done',
['Failed: done error']
);
@@ -1333,7 +1478,7 @@
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.describe('a suite', function() {
env.fit('is focused', function() {
@@ -1342,13 +1487,13 @@
env.it('is not focused', function() {
calls.push('freakout');
- })
+ });
});
env.execute();
});
- it('should only run focused suites', function(done){
+ it('should only run focused suites', function(done) {
var calls = [];
var assertions = function() {
@@ -1356,7 +1501,7 @@
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.fdescribe('a focused suite', function() {
env.it('is focused', function() {
@@ -1367,7 +1512,7 @@
env.describe('a regular suite', function() {
env.it('is not focused', function() {
calls.push('freakout');
- })
+ });
});
env.execute();
@@ -1375,13 +1520,13 @@
it('should run focused tests inside an xdescribe', function(done) {
var reporter = jasmine.createSpyObj('fakeReporter', [
- "jasmineStarted",
- "jasmineDone",
- "suiteStarted",
- "suiteDone",
- "specStarted",
- "specDone"
- ]);
+ 'jasmineStarted',
+ 'jasmineDone',
+ 'suiteStarted',
+ 'suiteDone',
+ 'specStarted',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
@@ -1389,18 +1534,20 @@
order: jasmine.any(jasmineUnderTest.Order)
});
- expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
- description: 'with a fit spec',
- status: 'failed'
- }));
+ expect(reporter.specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ description: 'with a fit spec',
+ status: 'failed'
+ })
+ );
done();
});
env.addReporter(reporter);
- env.xdescribe("xd suite", function() {
- env.fit("with a fit spec", function() {
+ env.xdescribe('xd suite', function() {
+ env.fit('with a fit spec', function() {
env.expect(true).toBe(false);
});
});
@@ -1410,13 +1557,13 @@
it('should run focused suites inside an xdescribe', function(done) {
var reporter = jasmine.createSpyObj('fakeReporter', [
- "jasmineStarted",
- "jasmineDone",
- "suiteStarted",
- "suiteDone",
- "specStarted",
- "specDone"
- ]);
+ 'jasmineStarted',
+ 'jasmineDone',
+ 'suiteStarted',
+ 'suiteDone',
+ 'specStarted',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
@@ -1424,19 +1571,21 @@
order: jasmine.any(jasmineUnderTest.Order)
});
- expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
- description: 'with a spec',
- status: 'failed'
- }));
+ expect(reporter.specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ description: 'with a spec',
+ status: 'failed'
+ })
+ );
done();
});
env.addReporter(reporter);
- env.xdescribe("xd suite", function() {
- env.fdescribe("fd suite", function() {
- env.it("with a spec", function() {
+ env.xdescribe('xd suite', function() {
+ env.fdescribe('fd suite', function() {
+ env.it('with a spec', function() {
env.expect(true).toBe(false);
});
});
@@ -1446,15 +1595,15 @@
});
});
- it("should report as expected", function(done) {
+ it('should report as expected', function(done) {
var reporter = jasmine.createSpyObj('fakeReporter', [
- "jasmineStarted",
- "jasmineDone",
- "suiteStarted",
- "suiteDone",
- "specStarted",
- "specDone"
- ]);
+ 'jasmineStarted',
+ 'jasmineDone',
+ 'suiteStarted',
+ 'suiteDone',
+ 'specStarted',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
@@ -1464,46 +1613,54 @@
expect(reporter.specDone.calls.count()).toBe(5);
- expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
- description: 'with a top level spec',
- status: 'passed'
- }));
+ expect(reporter.specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ description: 'with a top level spec',
+ status: 'passed'
+ })
+ );
- expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
- description: "with an x'ed spec",
- status: 'pending'
- }));
+ expect(reporter.specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ description: "with an x'ed spec",
+ status: 'pending'
+ })
+ );
- expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
- description: 'with a spec',
- status: 'failed'
- }));
+ expect(reporter.specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ description: 'with a spec',
+ status: 'failed'
+ })
+ );
- expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
- description: 'is pending',
- status: 'pending'
- }));
+ expect(reporter.specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ description: 'is pending',
+ status: 'pending'
+ })
+ );
var suiteDone = reporter.suiteDone.calls.argsFor(0)[0];
expect(typeof suiteDone.duration).toBe('number');
var suiteResult = reporter.suiteStarted.calls.argsFor(0)[0];
- expect(suiteResult.description).toEqual("A Suite");
+ expect(suiteResult.description).toEqual('A Suite');
done();
});
env.addReporter(reporter);
- env.describe("A Suite", function() {
- env.it("with a top level spec", function() {
+ env.describe('A Suite', function() {
+ env.it('with a top level spec', function() {
env.expect(true).toBe(true);
});
- env.describe("with a nested suite", function() {
+ env.describe('with a nested suite', function() {
env.xit("with an x'ed spec", function() {
env.expect(true).toBe(true);
});
- env.it("with a spec", function() {
+ env.it('with a spec', function() {
env.expect(true).toBe(false);
});
});
@@ -1519,16 +1676,16 @@
env.execute();
});
- it("should report the random seed at the beginning and end of execution", function(done) {
+ it('should report the random seed at the beginning and end of execution', function(done) {
var reporter = jasmine.createSpyObj('fakeReporter', [
- "jasmineStarted",
- "jasmineDone",
- "suiteStarted",
- "suiteDone",
- "specStarted",
- "specDone"
- ]);
- env.configure({random: true, seed: '123456'});
+ 'jasmineStarted',
+ 'jasmineDone',
+ 'suiteStarted',
+ 'suiteDone',
+ 'specStarted',
+ 'specDone'
+ ]);
+ env.configure({ random: true, seed: '123456' });
reporter.jasmineDone.and.callFake(function(doneArg) {
expect(reporter.jasmineStarted).toHaveBeenCalled();
@@ -1542,15 +1699,15 @@
});
env.addReporter(reporter);
- env.configure({random: true});
+ env.configure({ random: true });
env.execute();
});
it('should report pending spec messages', function(done) {
var reporter = jasmine.createSpyObj('fakeReporter', [
- 'specDone',
- 'jasmineDone'
- ]);
+ 'specDone',
+ 'jasmineDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
var specStatus = reporter.specDone.calls.argsFor(0)[0];
@@ -1584,9 +1741,9 @@
};
var reporter = jasmine.createSpyObj('fakeReporter', [
- 'specDone',
- 'jasmineDone'
- ]);
+ 'specDone',
+ 'jasmineDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
var specStatus = reporter.specDone.calls.argsFor(0)[0];
@@ -1610,9 +1767,9 @@
it('should report using fallback reporter', function(done) {
var reporter = jasmine.createSpyObj('fakeReporter', [
- 'specDone',
- 'jasmineDone'
- ]);
+ 'specDone',
+ 'jasmineDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
expect(reporter.specDone).toHaveBeenCalled();
@@ -1631,13 +1788,13 @@
it('should report xdescribes as expected', function(done) {
var reporter = jasmine.createSpyObj('fakeReporter', [
- "jasmineStarted",
- "jasmineDone",
- "suiteStarted",
- "suiteDone",
- "specStarted",
- "specDone"
- ]);
+ 'jasmineStarted',
+ 'jasmineDone',
+ 'suiteStarted',
+ 'suiteDone',
+ 'specStarted',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
@@ -1645,8 +1802,12 @@
order: jasmine.any(jasmineUnderTest.Order)
});
- expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ status: 'pending' }));
- expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({ description: 'xd out', status: 'pending' }));
+ expect(reporter.specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({ status: 'pending' })
+ );
+ expect(reporter.suiteDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({ description: 'xd out', status: 'pending' })
+ );
expect(reporter.suiteDone.calls.count()).toBe(4);
done();
@@ -1654,11 +1815,11 @@
env.addReporter(reporter);
- env.describe("A Suite", function() {
- env.describe("nested", function() {
- env.xdescribe("xd out", function() {
- env.describe("nested again", function() {
- env.it("with a spec", function() {
+ env.describe('A Suite', function() {
+ env.describe('nested', function() {
+ env.xdescribe('xd out', function() {
+ env.describe('nested again', function() {
+ env.it('with a spec', function() {
env.expect(true).toBe(false);
});
});
@@ -1669,129 +1830,138 @@
env.execute();
});
- it("should be possible to get full name from a spec", function() {
+ it('should be possible to get full name from a spec', function() {
var topLevelSpec, nestedSpec, doublyNestedSpec;
- env.describe("my tests", function() {
- topLevelSpec = env.it("are sometimes top level", function() {
- });
- env.describe("are sometimes", function() {
- nestedSpec = env.it("singly nested", function() {
- });
- env.describe("even", function() {
- doublyNestedSpec = env.it("doubly nested", function() {
- });
+ env.describe('my tests', function() {
+ topLevelSpec = env.it('are sometimes top level', function() {});
+ env.describe('are sometimes', function() {
+ nestedSpec = env.it('singly nested', function() {});
+ env.describe('even', function() {
+ doublyNestedSpec = env.it('doubly nested', function() {});
});
});
});
- expect(topLevelSpec.getFullName()).toBe("my tests are sometimes top level");
- expect(nestedSpec.getFullName()).toBe("my tests are sometimes singly nested");
- expect(doublyNestedSpec.getFullName()).toBe("my tests are sometimes even doubly nested");
+ expect(topLevelSpec.getFullName()).toBe('my tests are sometimes top level');
+ expect(nestedSpec.getFullName()).toBe(
+ 'my tests are sometimes singly nested'
+ );
+ expect(doublyNestedSpec.getFullName()).toBe(
+ 'my tests are sometimes even doubly nested'
+ );
});
- it("Custom equality testers should be per spec", function(done) {
+ it('Custom equality testers should be per spec', function(done) {
var reporter = jasmine.createSpyObj('fakeReporter', [
- "jasmineDone",
- "specDone"
- ]);
+ 'jasmineDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
var firstSpecResult = reporter.specDone.calls.first().args[0],
- secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
+ secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
- expect(firstSpecResult.status).toEqual("passed");
- expect(secondSpecResult.status).toEqual("failed");
+ expect(firstSpecResult.status).toEqual('passed');
+ expect(secondSpecResult.status).toEqual('failed');
done();
});
env.addReporter(reporter);
- env.configure({random: false});
+ env.configure({ random: false });
- env.describe("testing custom equality testers", function() {
- env.it("with a custom tester", function() {
- env.addCustomEqualityTester(function(a, b) { return true; });
- env.expect("a").toEqual("b");
+ env.describe('testing custom equality testers', function() {
+ env.it('with a custom tester', function() {
+ env.addCustomEqualityTester(function(a, b) {
+ return true;
+ });
+ env.expect('a').toEqual('b');
});
- env.it("without a custom tester", function() {
- env.expect("a").toEqual("b");
+ env.it('without a custom tester', function() {
+ env.expect('a').toEqual('b');
});
});
env.execute();
});
- it("Custom equality testers should be per suite", function(done) {
+ it('Custom equality testers should be per suite', function(done) {
var reporter = jasmine.createSpyObj('fakeReporter', [
- "jasmineDone",
- "specDone"
- ]);
+ 'jasmineDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
var firstSpecResult = reporter.specDone.calls.first().args[0],
- secondSpecResult = reporter.specDone.calls.argsFor(0)[0],
- thirdSpecResult = reporter.specDone.calls.mostRecent().args[0];
+ secondSpecResult = reporter.specDone.calls.argsFor(0)[0],
+ thirdSpecResult = reporter.specDone.calls.mostRecent().args[0];
- expect(firstSpecResult.status).toEqual("passed");
- expect(secondSpecResult.status).toEqual("passed");
- expect(thirdSpecResult.status).toEqual("failed");
+ expect(firstSpecResult.status).toEqual('passed');
+ expect(secondSpecResult.status).toEqual('passed');
+ expect(thirdSpecResult.status).toEqual('failed');
done();
});
env.addReporter(reporter);
- env.configure({random: false});
+ env.configure({ random: false });
- env.describe("testing custom equality testers", function() {
- env.beforeAll(function() { env.addCustomEqualityTester(function(a, b) { return true; }); });
-
- env.it("with a custom tester", function() {
- env.expect("a").toEqual("b");
+ env.describe('testing custom equality testers', function() {
+ env.beforeAll(function() {
+ env.addCustomEqualityTester(function(a, b) {
+ return true;
+ });
});
- env.it("with the same custom tester", function() {
- env.expect("a").toEqual("b");
+ env.it('with a custom tester', function() {
+ env.expect('a').toEqual('b');
+ });
+
+ env.it('with the same custom tester', function() {
+ env.expect('a').toEqual('b');
});
});
- env.describe("another suite", function() {
- env.it("without the custom tester", function(){
- env.expect("a").toEqual("b");
+ env.describe('another suite', function() {
+ env.it('without the custom tester', function() {
+ env.expect('a').toEqual('b');
});
});
env.execute();
});
- it("Custom equality testers for toContain should be per spec", function(done) {
+ it('Custom equality testers for toContain should be per spec', function(done) {
var reporter = jasmine.createSpyObj('fakeReporter', [
- "jasmineDone",
- "specDone"
- ]);
+ 'jasmineDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
var firstSpecResult = reporter.specDone.calls.first().args[0],
- secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
+ secondSpecResult = reporter.specDone.calls.mostRecent().args[0];
- expect(firstSpecResult.status).toEqual("passed");
- expect(secondSpecResult.status).toEqual("failed");
+ expect(firstSpecResult.status).toEqual('passed');
+ expect(secondSpecResult.status).toEqual('failed');
done();
});
env.addReporter(reporter);
- env.configure({random: false});
+ env.configure({ random: false });
- env.describe("testing custom equality testers", function() {
- env.it("with a custom tester", function() {
- env.addCustomEqualityTester(function(a, b) { return true; });
- env.expect(["a"]).toContain("b");
+ env.describe('testing custom equality testers', function() {
+ env.it('with a custom tester', function() {
+ env.addCustomEqualityTester(function(a, b) {
+ return true;
+ });
+ env.expect(['a']).toContain('b');
});
- env.it("without a custom tester", function() {
- env.expect(["a"]).toContain("b");
+ env.it('without a custom tester', function() {
+ env.expect(['a']).toContain('b');
});
});
@@ -1804,254 +1974,296 @@
reporter.jasmineDone.and.callFake(done);
env.addReporter(reporter);
- env.describe("A Suite", function() {
- env.it("an async spec that is actually synchronous", function(underTestCallback) {
+ env.describe('A Suite', function() {
+ env.it('an async spec that is actually synchronous', function(
+ underTestCallback
+ ) {
underTestCallback();
});
- expect(function() { env.expect('a').toEqual('a'); }).toThrowError(/'expect' was used when there was no current spec/);
+ expect(function() {
+ env.expect('a').toEqual('a');
+ }).toThrowError(/'expect' was used when there was no current spec/);
});
env.execute();
});
- it("Custom equality testers for toContain should be per suite", function(done) {
+ it('Custom equality testers for toContain should be per suite', function(done) {
var reporter = jasmine.createSpyObj('fakeReporter', [
- "jasmineDone",
- "specDone"
- ]);
+ 'jasmineDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
var firstSpecResult = reporter.specDone.calls.first().args[0],
- secondSpecResult = reporter.specDone.calls.argsFor(1)[0],
- thirdSpecResult = reporter.specDone.calls.mostRecent().args[0];
+ secondSpecResult = reporter.specDone.calls.argsFor(1)[0],
+ thirdSpecResult = reporter.specDone.calls.mostRecent().args[0];
- expect(firstSpecResult.status).toEqual("passed");
- expect(secondSpecResult.status).toEqual("passed");
- expect(thirdSpecResult.status).toEqual("failed");
+ expect(firstSpecResult.status).toEqual('passed');
+ expect(secondSpecResult.status).toEqual('passed');
+ expect(thirdSpecResult.status).toEqual('failed');
done();
});
env.addReporter(reporter);
- env.configure({random: false});
+ env.configure({ random: false });
- env.describe("testing custom equality testers", function() {
- env.beforeAll(function() { env.addCustomEqualityTester(function(a, b) { return true; })});
-
- env.it("with a custom tester", function() {
- env.expect(["a"]).toContain("b");
+ env.describe('testing custom equality testers', function() {
+ env.beforeAll(function() {
+ env.addCustomEqualityTester(function(a, b) {
+ return true;
+ });
});
- env.it("also with the custom tester", function() {
- env.expect(["a"]).toContain("b");
+ env.it('with a custom tester', function() {
+ env.expect(['a']).toContain('b');
+ });
+
+ env.it('also with the custom tester', function() {
+ env.expect(['a']).toContain('b');
});
});
- env.describe("another suite", function() {
- env.it("without the custom tester", function() {
- env.expect(["a"]).toContain("b");
+ env.describe('another suite', function() {
+ env.it('without the custom tester', function() {
+ env.expect(['a']).toContain('b');
});
});
env.execute();
});
- it("Custom matchers should be per spec", function(done) {
+ it('Custom matchers should be per spec', function(done) {
var matchers = {
- toFoo: function() {}
- };
+ toFoo: function() {}
+ };
- env.describe("testing custom matchers", function() {
- env.it("with a custom matcher", function() {
+ env.describe('testing custom matchers', function() {
+ env.it('with a custom matcher', function() {
env.addMatchers(matchers);
expect(env.expect().toFoo).toBeDefined();
});
- env.it("without a custom matcher", function() {
+ env.it('without a custom matcher', function() {
expect(env.expect().toFoo).toBeUndefined();
});
});
- env.addReporter({jasmineDone: done});
+ env.addReporter({ jasmineDone: done });
env.execute();
});
- it("Custom matchers should be per suite", function(done) {
+ it('Custom matchers should be per suite', function(done) {
var matchers = {
- toFoo: function() {}
- };
+ toFoo: function() {}
+ };
- env.describe("testing custom matchers", function() {
- env.beforeAll(function() { env.addMatchers(matchers); });
+ env.describe('testing custom matchers', function() {
+ env.beforeAll(function() {
+ env.addMatchers(matchers);
+ });
- env.it("with a custom matcher", function() {
+ env.it('with a custom matcher', function() {
expect(env.expect().toFoo).toBeDefined();
});
- env.it("with the same custom matcher", function() {
+ env.it('with the same custom matcher', function() {
expect(env.expect().toFoo).toBeDefined();
});
});
- env.describe("another suite", function() {
- env.it("no longer has the custom matcher", function() {
+ env.describe('another suite', function() {
+ env.it('no longer has the custom matcher', function() {
expect(env.expect().toFoo).not.toBeDefined();
});
});
- env.addReporter({jasmineDone: done});
+ env.addReporter({ jasmineDone: done });
env.execute();
});
- it('throws an exception if you try to create a spy outside of a runnable', function (done) {
- var obj = {fn: function () {}},
+ it('throws an exception if you try to create a spy outside of a runnable', function(done) {
+ var obj = { fn: function() {} },
exception;
- env.describe("a suite", function () {
+ env.describe('a suite', function() {
try {
env.spyOn(obj, 'fn');
- } catch(e) {
+ } catch (e) {
exception = e;
}
});
var assertions = function() {
- expect(exception.message).toBe('Spies must be created in a before function or a spec');
+ expect(exception.message).toBe(
+ 'Spies must be created in a before function or a spec'
+ );
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
- it('throws an exception if you try to add a matcher outside of a runnable', function (done) {
- var obj = {fn: function () {}},
+ it('throws an exception if you try to add a matcher outside of a runnable', function(done) {
+ var obj = { fn: function() {} },
exception;
- env.describe("a suite", function () {
+ env.describe('a suite', function() {
try {
- env.addMatchers({myMatcher: function(actual,expected){return false;}});
- } catch(e) {
+ env.addMatchers({
+ myMatcher: function(actual, expected) {
+ return false;
+ }
+ });
+ } catch (e) {
exception = e;
}
});
var assertions = function() {
- expect(exception.message).toBe('Matchers must be added in a before function or a spec');
+ expect(exception.message).toBe(
+ 'Matchers must be added in a before function or a spec'
+ );
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
- it('throws an exception if you try to add a custom equality outside of a runnable', function (done) {
- var obj = {fn: function () {}},
+ it('throws an exception if you try to add a custom equality outside of a runnable', function(done) {
+ var obj = { fn: function() {} },
exception;
- env.describe("a suite", function () {
+ env.describe('a suite', function() {
try {
- env.addCustomEqualityTester(function(first, second) {return true;});
- } catch(e) {
+ env.addCustomEqualityTester(function(first, second) {
+ return true;
+ });
+ } catch (e) {
exception = e;
}
});
var assertions = function() {
- expect(exception.message).toBe('Custom Equalities must be added in a before function or a spec');
+ expect(exception.message).toBe(
+ 'Custom Equalities must be added in a before function or a spec'
+ );
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
it('reports test properties on specs', function(done) {
- var env = new jasmineUnderTest.Env(),
- reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ var env = new jasmineUnderTest.Env(),
+ reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
- reporter.specDone.and.callFake(function(e) {
- expect(e.properties).toEqual({a: 'Bee'});
- done();
- });
+ reporter.specDone.and.callFake(function(e) {
+ expect(e.properties).toEqual({ a: 'Bee' });
+ done();
+ });
- env.addReporter(reporter);
- env.it('calls setSpecProperty', function() {
- env.setSpecProperty('a', 'Bee')
- });
- env.execute();
+ env.addReporter(reporter);
+ env.it('calls setSpecProperty', function() {
+ env.setSpecProperty('a', 'Bee');
+ });
+ env.execute();
});
- it('throws an exception if you try to setSpecProperty outside of a spec', function (done) {
+ it('throws an exception if you try to setSpecProperty outside of a spec', function(done) {
var env = new jasmineUnderTest.Env(),
- exception;
+ exception;
- env.describe("a suite", function () {
+ env.describe('a suite', function() {
try {
env.setSpecProperty('a prop', 'val');
- } catch(e) {
+ } catch (e) {
exception = e;
}
});
var assertions = function() {
- expect(exception.message).toBe("'setSpecProperty' was used when there was no current spec");
+ expect(exception.message).toBe(
+ "'setSpecProperty' was used when there was no current spec"
+ );
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
it('reports test properties on suites', function(done) {
- var env = new jasmineUnderTest.Env(),
- reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ var env = new jasmineUnderTest.Env(),
+ reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
- reporter.suiteDone.and.callFake(function(e) {
- expect(e.properties).toEqual({b: 'Sweet'});
- done();
+ reporter.suiteDone.and.callFake(function(e) {
+ expect(e.properties).toEqual({ b: 'Sweet' });
+ done();
+ });
+
+ env.addReporter(reporter);
+ env.describe('calls setSuiteProperty', function() {
+ env.beforeEach(function() {
+ env.setSuiteProperty('b', 'Sweet');
});
-
- env.addReporter(reporter);
- env.describe('calls setSuiteProperty', function() {
- env.beforeEach(function() {
- env.setSuiteProperty('b', 'Sweet');
- });
- env.it('a passing spec', function() {
- expect.nothing();
- });
+ env.it('a passing spec', function() {
+ expect.nothing();
});
+ });
- env.execute();
+ env.execute();
});
- it('throws an exception if you try to setSuiteProperty outside of a suite', function (done) {
+ it('throws an exception if you try to setSuiteProperty outside of a suite', function(done) {
var env = new jasmineUnderTest.Env();
try {
env.setSuiteProperty('a', 'Bee');
- } catch(e) {
- expect(e.message).toBe("'setSuiteProperty' was used when there was no current suite");
+ } catch (e) {
+ expect(e.message).toBe(
+ "'setSuiteProperty' was used when there was no current suite"
+ );
done();
}
});
- it("should associate errors thrown from async code with the correct runnable", function(done) {
- var reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone','specDone']);
+ it('should associate errors thrown from async code with the correct runnable', function(done) {
+ var reporter = jasmine.createSpyObj('fakeReport', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
- expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('async suite', [
- /^(((Uncaught )?(exception: )?Error: suite( thrown)?)|(suite thrown))$/
- ]);
- expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite async spec', [
- /^(((Uncaught )?(exception: )?Error: spec( thrown)?)|(spec thrown))$/
- ]);
+ expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
+ 'async suite',
+ [
+ /^(((Uncaught )?(exception: )?Error: suite( thrown)?)|(suite thrown))$/
+ ]
+ );
+ expect(reporter.specDone).toHaveFailedExpectationsForRunnable(
+ 'suite async spec',
+ [/^(((Uncaught )?(exception: )?Error: spec( thrown)?)|(spec thrown))$/]
+ );
done();
});
@@ -2059,40 +2271,81 @@
env.describe('async suite', function() {
env.afterAll(function(innerDone) {
- setTimeout(function() { throw new Error('suite'); }, 1);
+ setTimeout(function() {
+ throw new Error('suite');
+ }, 1);
}, 10);
env.it('spec', function() {});
});
env.describe('suite', function() {
- env.it('async spec', function(innerDone) {
- setTimeout(function() { throw new Error('spec'); }, 1);
- }, 10);
+ env.it(
+ 'async spec',
+ function(innerDone) {
+ setTimeout(function() {
+ throw new Error('spec');
+ }, 1);
+ },
+ 10
+ );
});
env.execute();
});
- it('should throw on suites/specs/befores/afters nested in methods other than \'describe\'', function(done) {
- var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ it("should throw on suites/specs/befores/afters nested in methods other than 'describe'", function(done) {
+ var reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function() {
var msg = /\'.*\' should only be used in \'describe\' function/;
- expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite describe', [msg]);
- expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite xdescribe', [msg]);
- expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite fdescribe', [msg]);
+ expect(reporter.specDone).toHaveFailedExpectationsForRunnable(
+ 'suite describe',
+ [msg]
+ );
+ expect(reporter.specDone).toHaveFailedExpectationsForRunnable(
+ 'suite xdescribe',
+ [msg]
+ );
+ expect(reporter.specDone).toHaveFailedExpectationsForRunnable(
+ 'suite fdescribe',
+ [msg]
+ );
- expect(reporter.specDone).toHaveFailedExpectationsForRunnable('spec it', [msg]);
- expect(reporter.specDone).toHaveFailedExpectationsForRunnable('spec xit', [msg]);
- expect(reporter.specDone).toHaveFailedExpectationsForRunnable('spec fit', [msg]);
+ expect(reporter.specDone).toHaveFailedExpectationsForRunnable('spec it', [
+ msg
+ ]);
+ expect(reporter.specDone).toHaveFailedExpectationsForRunnable(
+ 'spec xit',
+ [msg]
+ );
+ expect(reporter.specDone).toHaveFailedExpectationsForRunnable(
+ 'spec fit',
+ [msg]
+ );
- expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('beforeAll', [msg]);
- expect(reporter.specDone).toHaveFailedExpectationsForRunnable('beforeEach spec', [msg]);
+ expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
+ 'beforeAll',
+ [msg]
+ );
+ expect(reporter.specDone).toHaveFailedExpectationsForRunnable(
+ 'beforeEach spec',
+ [msg]
+ );
- expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('afterAll', [msg]);
- expect(reporter.specDone).toHaveFailedExpectationsForRunnable('afterEach spec', [msg]);
+ expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
+ 'afterAll',
+ [msg]
+ );
+ expect(reporter.specDone).toHaveFailedExpectationsForRunnable(
+ 'afterEach spec',
+ [msg]
+ );
done();
});
@@ -2100,34 +2353,54 @@
env.addReporter(reporter);
env.describe('suite', function() {
- env.it('describe', function() { env.describe('inner suite', function() {}); });
- env.it('xdescribe', function() { env.xdescribe('inner suite', function() {}); });
- env.it('fdescribe', function() { env.fdescribe('inner suite', function() {}); });
+ env.it('describe', function() {
+ env.describe('inner suite', function() {});
+ });
+ env.it('xdescribe', function() {
+ env.xdescribe('inner suite', function() {});
+ });
+ env.it('fdescribe', function() {
+ env.fdescribe('inner suite', function() {});
+ });
});
env.describe('spec', function() {
- env.it('it', function() { env.it('inner spec', function() {}); });
- env.it('xit', function() { env.xit('inner spec', function() {}); });
- env.it('fit', function() { env.fit('inner spec', function() {}); });
+ env.it('it', function() {
+ env.it('inner spec', function() {});
+ });
+ env.it('xit', function() {
+ env.xit('inner spec', function() {});
+ });
+ env.it('fit', function() {
+ env.fit('inner spec', function() {});
+ });
});
env.describe('beforeAll', function() {
- env.beforeAll(function() { env.beforeAll(function() {}); });
+ env.beforeAll(function() {
+ env.beforeAll(function() {});
+ });
env.it('spec', function() {});
});
env.describe('beforeEach', function() {
- env.beforeEach(function() { env.beforeEach(function() {}); });
+ env.beforeEach(function() {
+ env.beforeEach(function() {});
+ });
env.it('spec', function() {});
});
env.describe('afterAll', function() {
- env.afterAll(function() { env.afterAll(function() {}); });
+ env.afterAll(function() {
+ env.afterAll(function() {});
+ });
env.it('spec', function() {});
});
env.describe('afterEach', function() {
- env.afterEach(function() { env.afterEach(function() {}); });
+ env.afterEach(function() {
+ env.afterEach(function() {});
+ });
env.it('spec', function() {});
});
@@ -2136,15 +2409,23 @@
it('reports errors that occur during loading', function(done) {
var global = {
- setTimeout: function(fn, delay) { setTimeout(fn, delay) },
- clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
+ setTimeout: function(fn, delay) {
+ setTimeout(fn, delay);
+ },
+ clearTimeout: function(fn, delay) {
+ clearTimeout(fn, delay);
+ },
onerror: function() {}
};
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
env.cleanup_();
env = new jasmineUnderTest.Env();
- var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ var reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.failedExpectations).toEqual([
@@ -2170,7 +2451,13 @@
});
env.addReporter(reporter);
- global.onerror('Uncaught SyntaxError: Unexpected end of input', 'borkenSpec.js', 42, undefined, {stack: 'a stack'});
+ global.onerror(
+ 'Uncaught SyntaxError: Unexpected end of input',
+ 'borkenSpec.js',
+ 42,
+ undefined,
+ { stack: 'a stack' }
+ );
global.onerror('Uncaught Error: ENOCHEESE');
env.execute();
@@ -2178,10 +2465,14 @@
describe('If suppressLoadErrors: true was passed', function() {
it('does not install a global error handler during loading', function(done) {
- var originalOnerror = jasmine.createSpy('original onerror')
+ var originalOnerror = jasmine.createSpy('original onerror');
var global = {
- setTimeout: function(fn, delay) { setTimeout(fn, delay) },
- clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
+ setTimeout: function(fn, delay) {
+ setTimeout(fn, delay);
+ },
+ clearTimeout: function(fn, delay) {
+ clearTimeout(fn, delay);
+ },
onerror: originalOnerror
};
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
@@ -2191,12 +2482,18 @@
spyOn(jasmineUnderTest, 'GlobalErrors').and.returnValue(globalErrors);
env.cleanup_();
- env = new jasmineUnderTest.Env({suppressLoadErrors: true});
- var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ env = new jasmineUnderTest.Env({ suppressLoadErrors: true });
+ var reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.failedExpectations).toEqual([]);
- expect(originalOnerror).toHaveBeenCalledWith('Uncaught Error: ENOCHEESE');
+ expect(originalOnerror).toHaveBeenCalledWith(
+ 'Uncaught Error: ENOCHEESE'
+ );
done();
});
@@ -2210,7 +2507,11 @@
describe('Overall status in the jasmineDone event', function() {
describe('When everything passes', function() {
it('is "passed"', function(done) {
- var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ var reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.overallStatus).toEqual('passed');
@@ -2225,7 +2526,11 @@
describe('When a spec fails', function() {
it('is "failed"', function(done) {
- var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ var reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.overallStatus).toEqual('failed');
@@ -2244,13 +2549,16 @@
var reporter;
beforeEach(function() {
- reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
env.addReporter(reporter);
env.it('is a spec without any expectations', function() {
// does nothing, just a mock spec without expectations
});
-
});
it('should report "failed" status if "failSpecWithNoExpectations" is enabled', function(done) {
@@ -2276,7 +2584,11 @@
describe('When a top-level beforeAll fails', function() {
it('is "failed"', function(done) {
- var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ var reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.overallStatus).toEqual('failed');
@@ -2294,7 +2606,11 @@
describe('When a suite beforeAll fails', function() {
it('is "failed"', function(done) {
- var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ var reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.overallStatus).toEqual('failed');
@@ -2314,7 +2630,11 @@
describe('When a top-level afterAll fails', function() {
it('is "failed"', function(done) {
- var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ var reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.overallStatus).toEqual('failed');
@@ -2332,7 +2652,11 @@
describe('When a suite afterAll fails', function() {
it('is "failed"', function(done) {
- var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ var reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.overallStatus).toEqual('failed');
@@ -2350,17 +2674,25 @@
});
});
- describe("When there are load errors", function() {
+ describe('When there are load errors', function() {
it('is "failed"', function(done) {
var global = {
- setTimeout: function(fn, delay) { setTimeout(fn, delay) },
- clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
+ setTimeout: function(fn, delay) {
+ setTimeout(fn, delay);
+ },
+ clearTimeout: function(fn, delay) {
+ clearTimeout(fn, delay);
+ }
};
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
env.cleanup_();
env = new jasmineUnderTest.Env();
- var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ var reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.overallStatus).toEqual('failed');
@@ -2376,7 +2708,11 @@
describe('When there are no specs', function() {
it('is "incomplete"', function(done) {
- var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ var reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.overallStatus).toEqual('incomplete');
@@ -2391,7 +2727,11 @@
describe('When a spec is focused', function() {
it('is "incomplete"', function(done) {
- var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ var reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.overallStatus).toEqual('incomplete');
@@ -2407,7 +2747,11 @@
describe('When a suite is focused', function() {
it('is "incomplete"', function(done) {
- var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ var reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.overallStatus).toEqual('incomplete');
@@ -2425,7 +2769,11 @@
describe('When there are both failures and focused specs', function() {
it('is "failed"', function(done) {
- var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ var reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.overallStatus).toEqual('failed');
@@ -2443,29 +2791,37 @@
});
it('should report deprecation warnings on the correct specs and suites', function(done) {
- var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
+ var reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]);
// prevent deprecation from being displayed
- spyOn(console, "error");
+ spyOn(console, 'error');
reporter.jasmineDone.and.callFake(function(result) {
expect(result.deprecationWarnings).toEqual([
jasmine.objectContaining({ message: 'top level deprecation' })
]);
- expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
- fullName: 'suite',
- deprecationWarnings: [
- jasmine.objectContaining({ message: 'suite level deprecation' })
- ]
- }));
+ expect(reporter.suiteDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ fullName: 'suite',
+ deprecationWarnings: [
+ jasmine.objectContaining({ message: 'suite level deprecation' })
+ ]
+ })
+ );
- expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
- fullName: 'suite spec',
- deprecationWarnings: [
- jasmine.objectContaining({ message: 'spec level deprecation' })
- ]
- }));
+ expect(reporter.specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ fullName: 'suite spec',
+ deprecationWarnings: [
+ jasmine.objectContaining({ message: 'spec level deprecation' })
+ ]
+ })
+ );
done();
});
@@ -2489,15 +2845,33 @@
it('should report deprecation stack with an error object', function(done) {
var exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
- reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']),
- topLevelError, suiteLevelError, specLevelError;
+ reporter = jasmine.createSpyObj('reporter', [
+ 'jasmineDone',
+ 'suiteDone',
+ 'specDone'
+ ]),
+ topLevelError,
+ suiteLevelError,
+ specLevelError;
- try { throw new Error('top level deprecation') } catch (err) { topLevelError = err; }
- try { throw new Error('suite level deprecation') } catch (err) { suiteLevelError = err; }
- try { throw new Error('spec level deprecation') } catch (err) { specLevelError = err; }
+ try {
+ throw new Error('top level deprecation');
+ } catch (err) {
+ topLevelError = err;
+ }
+ try {
+ throw new Error('suite level deprecation');
+ } catch (err) {
+ suiteLevelError = err;
+ }
+ try {
+ throw new Error('spec level deprecation');
+ } catch (err) {
+ specLevelError = err;
+ }
// prevent deprecation from being displayed
- spyOn(console, "error");
+ spyOn(console, 'error');
reporter.jasmineDone.and.callFake(function(result) {
expect(result.deprecationWarnings).toEqual([
@@ -2507,25 +2881,29 @@
})
]);
- expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
- fullName: 'suite',
- deprecationWarnings: [
- jasmine.objectContaining({
- message: suiteLevelError.message,
- stack: exceptionFormatter.stack(suiteLevelError)
- })
- ]
- }));
+ expect(reporter.suiteDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ fullName: 'suite',
+ deprecationWarnings: [
+ jasmine.objectContaining({
+ message: suiteLevelError.message,
+ stack: exceptionFormatter.stack(suiteLevelError)
+ })
+ ]
+ })
+ );
- expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
- fullName: 'suite spec',
- deprecationWarnings: [
- jasmine.objectContaining({
- message: specLevelError.message,
- stack: exceptionFormatter.stack(specLevelError)
- })
- ]
- }));
+ expect(reporter.specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ fullName: 'suite spec',
+ deprecationWarnings: [
+ jasmine.objectContaining({
+ message: specLevelError.message,
+ stack: exceptionFormatter.stack(specLevelError)
+ })
+ ]
+ })
+ );
done();
});
@@ -2551,29 +2929,39 @@
jasmine.getEnv().requirePromises();
var specDone = jasmine.createSpy('specDone'),
- suiteDone = jasmine.createSpy('suiteDone');
+ suiteDone = jasmine.createSpy('suiteDone');
env.addReporter({
specDone: specDone,
suiteDone: suiteDone,
jasmineDone: function(result) {
- expect(result.failedExpectations).toEqual([jasmine.objectContaining({
+ expect(result.failedExpectations).toEqual([
+ jasmine.objectContaining({
message: 'Expected [object Promise] to be rejected.'
- })]);
+ })
+ ]);
- expect(specDone).toHaveBeenCalledWith(jasmine.objectContaining({
- description: 'has an async failure',
- failedExpectations: [jasmine.objectContaining({
- message: 'Expected [object Promise] to be rejected.'
- })]
- }));
+ expect(specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ description: 'has an async failure',
+ failedExpectations: [
+ jasmine.objectContaining({
+ message: 'Expected [object Promise] to be rejected.'
+ })
+ ]
+ })
+ );
- expect(suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
- description: 'a suite',
- failedExpectations: [jasmine.objectContaining({
- message: 'Expected [object Promise] to be rejected.'
- })]
- }));
+ expect(suiteDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ description: 'a suite',
+ failedExpectations: [
+ jasmine.objectContaining({
+ message: 'Expected [object Promise] to be rejected.'
+ })
+ ]
+ })
+ );
done();
}
@@ -2581,8 +2969,13 @@
function fail(innerDone) {
var resolve;
- var p = new Promise(function(res, rej) { resolve = res }); // eslint-disable-line compat/compat
- env.expectAsync(p).toBeRejected().then(innerDone);
+ var p = new Promise(function(res, rej) {
+ resolve = res;
+ }); // eslint-disable-line compat/compat
+ env
+ .expectAsync(p)
+ .toBeRejected()
+ .then(innerDone);
resolve();
}
@@ -2603,16 +2996,20 @@
env.addReporter({
specDone: specDone,
jasmineDone: function() {
- expect(specDone).toHaveBeenCalledWith(jasmine.objectContaining({
- description: 'has an async failure',
- failedExpectations: []
- }));
+ expect(specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ description: 'has an async failure',
+ failedExpectations: []
+ })
+ );
done();
}
});
env.it('has an async failure', function() {
- env.addCustomEqualityTester(function() { return true; });
+ env.addCustomEqualityTester(function() {
+ return true;
+ });
var p = Promise.resolve('something'); // eslint-disable-line compat/compat
return env.expectAsync(p).toBeResolvedTo('something else');
});
@@ -2628,17 +3025,23 @@
env.addReporter({
specDone: specDone,
jasmineDone: function() {
- expect(specDone).toHaveBeenCalledWith(jasmine.objectContaining({
- failedExpectations: [jasmine.objectContaining({
- stack: jasmine.stringMatching('EnvSpec.js')
- })]
- }));
+ expect(specDone).toHaveBeenCalledWith(
+ jasmine.objectContaining({
+ failedExpectations: [
+ jasmine.objectContaining({
+ stack: jasmine.stringMatching('EnvSpec.js')
+ })
+ ]
+ })
+ );
done();
}
});
env.it('has an async failure', function() {
- env.addCustomEqualityTester(function() { return true; });
+ env.addCustomEqualityTester(function() {
+ return true;
+ });
var p = Promise.resolve(); // eslint-disable-line compat/compat
return env.expectAsync(p).toBeRejected();
});
@@ -2650,7 +3053,9 @@
jasmine.getEnv().requirePromises();
var resolve,
- promise = new Promise(function(res) { resolve = res; }); // eslint-disable-line compat/compat
+ promise = new Promise(function(res) {
+ resolve = res;
+ }); // eslint-disable-line compat/compat
env.describe('a suite', function() {
env.it('does not wait', function() {
@@ -2665,12 +3070,13 @@
specDone: function() {
resolve();
},
- jasmineDone: function (result) {
+ jasmineDone: function(result) {
expect(result.failedExpectations).toEqual([
jasmine.objectContaining({
passed: false,
globalErrorType: 'lateExpectation',
- message: 'Spec "a suite does not wait" ran a "toBeResolved" expectation ' +
+ message:
+ 'Spec "a suite does not wait" ran a "toBeResolved" expectation ' +
'after it finished.\n' +
'Did you forget to return or await the result of expectAsync?',
matcherName: 'toBeResolved'
@@ -2678,9 +3084,10 @@
jasmine.objectContaining({
passed: false,
globalErrorType: 'lateExpectation',
- message: 'Spec "a suite does not wait" ran a "toBeResolvedTo" expectation ' +
+ message:
+ 'Spec "a suite does not wait" ran a "toBeResolvedTo" expectation ' +
'after it finished.\n' +
- 'Message: "Expected a promise to be resolved to \'something else\' ' +
+ "Message: \"Expected a promise to be resolved to 'something else' " +
'but it was resolved to undefined."\n' +
'Did you forget to return or await the result of expectAsync?',
matcherName: 'toBeResolvedTo'
@@ -2698,7 +3105,9 @@
jasmine.getEnv().requirePromises();
var resolve,
- promise = new Promise(function(res) { resolve = res; }); // eslint-disable-line compat/compat
+ promise = new Promise(function(res) {
+ resolve = res;
+ }); // eslint-disable-line compat/compat
env.describe('a suite', function() {
env.afterAll(function() {
@@ -2714,12 +3123,13 @@
suiteDone: function() {
resolve();
},
- jasmineDone: function (result) {
+ jasmineDone: function(result) {
expect(result.failedExpectations).toEqual([
jasmine.objectContaining({
passed: false,
globalErrorType: 'lateExpectation',
- message: 'Suite "a suite" ran a "toBeResolved" expectation ' +
+ message:
+ 'Suite "a suite" ran a "toBeResolved" expectation ' +
'after it finished.\n' +
'Did you forget to return or await the result of expectAsync?',
matcherName: 'toBeResolved'
@@ -2733,25 +3143,25 @@
env.execute();
});
- it("supports asymmetric equality testers that take a matchersUtil", function(done) {
+ it('supports asymmetric equality testers that take a matchersUtil', function(done) {
var env = new jasmineUnderTest.Env();
- env.it("spec using custom asymmetric equality tester", function() {
+ env.it('spec using custom asymmetric equality tester', function() {
var customEqualityFn = function(a, b) {
- if (a === 2 && b === "two") {
+ if (a === 2 && b === 'two') {
return true;
}
};
var arrayWithFirstElement = function(sample) {
return {
- asymmetricMatch: function (actual, matchersUtil) {
+ asymmetricMatch: function(actual, matchersUtil) {
return matchersUtil.equals(sample, actual[0]);
}
};
};
env.addCustomEqualityTester(customEqualityFn);
- env.expect(["two"]).toEqual(arrayWithFirstElement(2));
+ env.expect(['two']).toEqual(arrayWithFirstElement(2));
});
var specExpectations = function(result) {
diff --git a/spec/core/integration/MatchersSpec.js b/spec/core/integration/MatchersSpec.js
index 92b7307..8907ecf 100644
--- a/spec/core/integration/MatchersSpec.js
+++ b/spec/core/integration/MatchersSpec.js
@@ -23,7 +23,9 @@
expect(result.failedExpectations.length)
.withContext('Number of failed expectations')
.toEqual(0);
- expect(result.failedExpectations[0] && result.failedExpectations[0].message)
+ expect(
+ result.failedExpectations[0] && result.failedExpectations[0].message
+ )
.withContext('Failure message')
.toBeUndefined();
};
@@ -45,12 +47,17 @@
.withContext('Number of failed expectations')
.toEqual(1);
expect(result.failedExpectations[0].message)
- .withContext('Failed with a thrown error rather than a matcher failure')
+ .withContext(
+ 'Failed with a thrown error rather than a matcher failure'
+ )
.not.toMatch(/^Error: /);
expect(result.failedExpectations[0].message)
- .withContext('Failed with a thrown type error rather than a matcher failure')
+ .withContext(
+ 'Failed with a thrown type error rather than a matcher failure'
+ )
.not.toMatch(/^TypeError: /);
- expect(result.failedExpectations[0].matcherName).withContext('Matcher name')
+ expect(result.failedExpectations[0].matcherName)
+ .withContext('Matcher name')
.not.toEqual('');
};
@@ -61,21 +68,22 @@
function verifyFailsWithCustomObjectFormatters(config) {
it('uses custom object formatters', function(done) {
- env.it('a spec', function () {
+ env.it('a spec', function() {
env.addCustomObjectFormatter(config.formatter);
config.expectations(env);
});
- var specExpectations = function (result) {
+ var specExpectations = function(result) {
expect(result.status).toEqual('failed');
expect(result.failedExpectations.length)
.withContext('Number of failed expectations')
.toEqual(1);
- expect(result.failedExpectations[0].message)
- .toEqual(config.expectedMessage);
+ expect(result.failedExpectations[0].message).toEqual(
+ config.expectedMessage
+ );
};
- env.addReporter({specDone: specExpectations, jasmineDone: done});
+ env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
}
@@ -96,7 +104,9 @@
expect(result.failedExpectations.length)
.withContext('Number of failed expectations')
.toEqual(0);
- expect(result.failedExpectations[0] && result.failedExpectations[0].message)
+ expect(
+ result.failedExpectations[0] && result.failedExpectations[0].message
+ )
.withContext('Failure message')
.toBeUndefined();
};
@@ -120,9 +130,12 @@
.withContext('Number of failed expectations')
.toEqual(1);
expect(result.failedExpectations[0].message)
- .withContext('Failed with a thrown error rather than a matcher failure')
+ .withContext(
+ 'Failed with a thrown error rather than a matcher failure'
+ )
.not.toMatch(/^Error: /);
- expect(result.failedExpectations[0].matcherName).withContext('Matcher name')
+ expect(result.failedExpectations[0].matcherName)
+ .withContext('Matcher name')
.not.toEqual('');
};
@@ -135,26 +148,26 @@
it('uses custom object formatters', function(done) {
var env = new jasmineUnderTest.Env();
jasmine.getEnv().requirePromises();
- env.it('a spec', function () {
+ env.it('a spec', function() {
env.addCustomObjectFormatter(config.formatter);
return config.expectations(env);
});
- var specExpectations = function (result) {
+ var specExpectations = function(result) {
expect(result.status).toEqual('failed');
expect(result.failedExpectations.length)
.withContext('Number of failed expectations')
.toEqual(1);
- expect(result.failedExpectations[0].message)
- .toEqual(config.expectedMessage);
+ expect(result.failedExpectations[0].message).toEqual(
+ config.expectedMessage
+ );
};
- env.addReporter({specDone: specExpectations, jasmineDone: done});
+ env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
}
-
describe('nothing', function() {
verifyPasses(function(env) {
env.expect().nothing();
@@ -330,7 +343,7 @@
env.expect(1).toBePositiveInfinity();
},
expectedMessage: 'Expected |1| to be Infinity.'
- })
+ });
});
describe('toBeResolved', function() {
@@ -362,7 +375,8 @@
expectations: function(env) {
return env.expectAsync(Promise.resolve('x')).toBeResolvedTo('y'); // eslint-disable-line compat/compat
},
- expectedMessage: 'Expected a promise to be resolved to |y| ' +
+ expectedMessage:
+ 'Expected a promise to be resolved to |y| ' +
'but it was resolved to |x|.'
});
});
@@ -396,14 +410,17 @@
expectations: function(env) {
return env.expectAsync(Promise.reject('x')).toBeRejectedWith('y'); // eslint-disable-line compat/compat
},
- expectedMessage: 'Expected a promise to be rejected with |y| ' +
+ expectedMessage:
+ 'Expected a promise to be rejected with |y| ' +
'but it was rejected with |x|.'
});
});
describe('toBeRejectedWithError', function() {
verifyPassesAsync(function(env) {
- return env.expectAsync(Promise.reject(new Error())).toBeRejectedWithError(Error); // eslint-disable-line compat/compat
+ return env
+ .expectAsync(Promise.reject(new Error()))
+ .toBeRejectedWithError(Error); // eslint-disable-line compat/compat
});
verifyFailsAsync(function(env) {
@@ -415,9 +432,12 @@
return '|' + val + '|';
},
expectations: function(env) {
- return env.expectAsync(Promise.reject('foo')).toBeRejectedWithError('foo'); // eslint-disable-line compat/compat
+ return env
+ .expectAsync(Promise.reject('foo'))
+ .toBeRejectedWithError('foo'); // eslint-disable-line compat/compat
},
- expectedMessage: 'Expected a promise to be rejected with Error: |foo| ' +
+ expectedMessage:
+ 'Expected a promise to be rejected with Error: |foo| ' +
'but it was rejected with |foo|.'
});
});
@@ -486,7 +506,7 @@
}
},
expectations: function(env) {
- env.expect([{foo: 4}]).toEqual([{foo: 5}]);
+ env.expect([{ foo: 4 }]).toEqual([{ foo: 5 }]);
},
expectedMessage: 'Expected $[0].foo = four to equal five.'
});
@@ -494,11 +514,11 @@
describe('toHaveSize', function() {
verifyPasses(function(env) {
- env.expect(['a','b']).toHaveSize(2);
+ env.expect(['a', 'b']).toHaveSize(2);
});
verifyFails(function(env) {
- env.expect(['a','b']).toHaveSize(1);
+ env.expect(['a', 'b']).toHaveSize(1);
});
});
@@ -517,14 +537,16 @@
describe('toHaveBeenCalledBefore', function() {
verifyPasses(function(env) {
- var a = env.createSpy('a'), b = env.createSpy('b');
+ var a = env.createSpy('a'),
+ b = env.createSpy('b');
a();
b();
env.expect(a).toHaveBeenCalledBefore(b);
});
verifyFails(function(env) {
- var a = env.createSpy('a'), b = env.createSpy('b');
+ var a = env.createSpy('a'),
+ b = env.createSpy('b');
b();
a();
env.expect(a).toHaveBeenCalledBefore(b);
@@ -567,7 +589,8 @@
var spy = env.createSpy('foo');
env.expect(spy).toHaveBeenCalledWith('x');
},
- expectedMessage: 'Expected spy foo to have been called with:\n' +
+ expectedMessage:
+ 'Expected spy foo to have been called with:\n' +
' |x|\n' +
'but it was never called.'
});
@@ -622,7 +645,11 @@
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
- env.expect(function() { throw '5'; }).toThrow(5);
+ env
+ .expect(function() {
+ throw '5';
+ })
+ .toThrow(5);
});
verifyFails(function(env) {
@@ -635,9 +662,11 @@
},
expectations: function(env) {
var spy = env.createSpy('foo');
- env.expect(function() {
- throw 'x'
- }).not.toThrow();
+ env
+ .expect(function() {
+ throw 'x';
+ })
+ .not.toThrow();
},
expectedMessage: 'Expected function not to throw, but it threw |x|.'
});
@@ -645,11 +674,15 @@
describe('toThrowError', function() {
verifyPasses(function(env) {
- env.expect(function() { throw new Error(); }).toThrowError();
+ env
+ .expect(function() {
+ throw new Error();
+ })
+ .toThrowError();
});
verifyFails(function(env) {
- env.expect(function() { }).toThrowError();
+ env.expect(function() {}).toThrowError();
});
verifyFailsWithCustomObjectFormatters({
@@ -658,9 +691,11 @@
},
expectations: function(env) {
var spy = env.createSpy('foo');
- env.expect(function() {
- throw 'x'
- }).toThrowError();
+ env
+ .expect(function() {
+ throw 'x';
+ })
+ .toThrowError();
},
expectedMessage: 'Expected function to throw an Error, but it threw |x|.'
});
@@ -672,11 +707,15 @@
}
verifyPasses(function(env) {
- env.expect(throws).toThrowMatching(function() { return true; });
+ env.expect(throws).toThrowMatching(function() {
+ return true;
+ });
});
verifyFails(function(env) {
- env.expect(throws).toThrowMatching(function() { return false; });
+ env.expect(throws).toThrowMatching(function() {
+ return false;
+ });
});
verifyFailsWithCustomObjectFormatters({
@@ -685,13 +724,16 @@
},
expectations: function(env) {
var spy = env.createSpy('foo');
- env.expect(function() {
- throw new Error('nope')
- }).toThrowMatching(function() {
- return false;
- });
+ env
+ .expect(function() {
+ throw new Error('nope');
+ })
+ .toThrowMatching(function() {
+ return false;
+ });
},
- expectedMessage: 'Expected function to throw an exception matching ' +
+ expectedMessage:
+ 'Expected function to throw an exception matching ' +
'a predicate, but it threw Error with message |nope|.'
});
});
diff --git a/spec/core/integration/SpecRunningSpec.js b/spec/core/integration/SpecRunningSpec.js
index d522cf8..7e87eb3 100644
--- a/spec/core/integration/SpecRunningSpec.js
+++ b/spec/core/integration/SpecRunningSpec.js
@@ -1,10 +1,10 @@
-describe("spec running", function () {
+describe('spec running', function() {
var env;
beforeEach(function() {
jasmine.getEnv().registerIntegrationMatchers();
env = new jasmineUnderTest.Env();
- env.configure({random: false});
+ env.configure({ random: false });
});
afterEach(function() {
@@ -14,18 +14,13 @@
it('should assign spec ids sequentially', function() {
var it0, it1, it2, it3, it4;
env.describe('test suite', function() {
- it0 = env.it('spec 0', function() {
- });
- it1 = env.it('spec 1', function() {
- });
- it2 = env.xit('spec 2', function() {
- });
- it3 = env.it('spec 3', function() {
- });
+ it0 = env.it('spec 0', function() {});
+ it1 = env.it('spec 1', function() {});
+ it2 = env.xit('spec 2', function() {});
+ it3 = env.it('spec 3', function() {});
});
env.describe('test suite 2', function() {
- it4 = env.it('spec 4', function() {
- });
+ it4 = env.it('spec 4', function() {});
});
expect(it0.id).toEqual('spec0');
@@ -35,29 +30,28 @@
expect(it4.id).toEqual('spec4');
});
- it('nested suites', function (done) {
-
+ it('nested suites', function(done) {
var foo = 0;
var bar = 0;
var baz = 0;
var quux = 0;
- var nested = env.describe('suite', function () {
- env.describe('nested', function () {
- env.it('should run nested suites', function () {
+ var nested = env.describe('suite', function() {
+ env.describe('nested', function() {
+ env.it('should run nested suites', function() {
foo++;
});
- env.it('should run nested suites', function () {
+ env.it('should run nested suites', function() {
bar++;
});
});
- env.describe('nested 2', function () {
- env.it('should run suites following nested suites', function () {
+ env.describe('nested 2', function() {
+ env.it('should run suites following nested suites', function() {
baz++;
});
});
- env.it('should run tests following nested suites', function () {
+ env.it('should run tests following nested suites', function() {
quux++;
});
});
@@ -79,14 +73,14 @@
env.execute();
});
- it("should permit nested describes", function(done) {
+ it('should permit nested describes', function(done) {
var actions = [];
- env.beforeEach(function () {
+ env.beforeEach(function() {
actions.push('topSuite beforeEach');
});
- env.afterEach(function () {
+ env.afterEach(function() {
actions.push('topSuite afterEach');
});
@@ -138,44 +132,44 @@
var assertions = function() {
var expected = [
- "topSuite beforeEach",
- "outer beforeEach",
- "outer it 1",
- "outer afterEach",
- "topSuite afterEach",
+ 'topSuite beforeEach',
+ 'outer beforeEach',
+ 'outer it 1',
+ 'outer afterEach',
+ 'topSuite afterEach',
- "topSuite beforeEach",
- "outer beforeEach",
- "inner 1 beforeEach",
- "inner 1 it",
- "inner 1 afterEach",
- "outer afterEach",
- "topSuite afterEach",
+ 'topSuite beforeEach',
+ 'outer beforeEach',
+ 'inner 1 beforeEach',
+ 'inner 1 it',
+ 'inner 1 afterEach',
+ 'outer afterEach',
+ 'topSuite afterEach',
- "topSuite beforeEach",
- "outer beforeEach",
- "outer it 2",
- "outer afterEach",
- "topSuite afterEach",
+ 'topSuite beforeEach',
+ 'outer beforeEach',
+ 'outer it 2',
+ 'outer afterEach',
+ 'topSuite afterEach',
- "topSuite beforeEach",
- "outer beforeEach",
- "inner 2 beforeEach",
- "inner 2 it",
- "inner 2 afterEach",
- "outer afterEach",
- "topSuite afterEach"
+ 'topSuite beforeEach',
+ 'outer beforeEach',
+ 'inner 2 beforeEach',
+ 'inner 2 it',
+ 'inner 2 afterEach',
+ 'outer afterEach',
+ 'topSuite afterEach'
];
expect(actions).toEqual(expected);
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
- it("should run multiple befores and afters ordered so functions declared later are treated as more specific", function(done) {
+ it('should run multiple befores and afters ordered so functions declared later are treated as more specific', function(done) {
var actions = [];
env.beforeAll(function() {
@@ -194,19 +188,19 @@
actions.push('runner afterAll2');
});
- env.beforeEach(function () {
+ env.beforeEach(function() {
actions.push('runner beforeEach1');
});
- env.afterEach(function () {
+ env.afterEach(function() {
actions.push('runner afterEach1');
});
- env.beforeEach(function () {
+ env.beforeEach(function() {
actions.push('runner beforeEach2');
});
- env.afterEach(function () {
+ env.afterEach(function() {
actions.push('runner afterEach2');
});
@@ -234,25 +228,25 @@
var assertions = function() {
var expected = [
- "runner beforeAll1",
- "runner beforeAll2",
- "runner beforeEach1",
- "runner beforeEach2",
- "beforeEach1",
- "beforeEach2",
- "outer it 1",
- "afterEach2",
- "afterEach1",
- "runner afterEach2",
- "runner afterEach1",
- "runner afterAll2",
- "runner afterAll1"
+ 'runner beforeAll1',
+ 'runner beforeAll2',
+ 'runner beforeEach1',
+ 'runner beforeEach2',
+ 'beforeEach1',
+ 'beforeEach2',
+ 'outer it 1',
+ 'afterEach2',
+ 'afterEach1',
+ 'runner afterEach2',
+ 'runner afterEach1',
+ 'runner afterAll2',
+ 'runner afterAll1'
];
expect(actions).toEqual(expected);
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
@@ -268,11 +262,11 @@
actions.push('runner afterAll');
});
- env.beforeEach(function () {
+ env.beforeEach(function() {
actions.push('runner beforeEach');
});
- env.afterEach(function () {
+ env.afterEach(function() {
actions.push('runner afterEach');
});
@@ -300,21 +294,21 @@
var assertions = function() {
var expected = [
- "runner beforeAll",
- "inner beforeAll",
- "runner beforeEach",
- "inner beforeEach",
- "it",
- "inner afterEach",
- "runner afterEach",
- "inner afterAll",
- "runner afterAll"
+ 'runner beforeAll',
+ 'inner beforeAll',
+ 'runner beforeEach',
+ 'inner beforeEach',
+ 'it',
+ 'inner afterEach',
+ 'runner afterEach',
+ 'inner afterAll',
+ 'runner afterAll'
];
expect(actions).toEqual(expected);
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
@@ -331,11 +325,11 @@
actions.push('runner afterAll');
});
- env.beforeEach(function () {
+ env.beforeEach(function() {
actions.push('runner beforeEach');
});
- env.afterEach(function () {
+ env.afterEach(function() {
actions.push('runner afterEach');
});
@@ -367,41 +361,41 @@
var assertions = function() {
var expected = [
- "runner beforeAll",
- "inner beforeAll",
- "runner beforeEach",
- "inner beforeEach",
- "it2",
- "inner afterEach",
- "runner afterEach",
+ 'runner beforeAll',
+ 'inner beforeAll',
+ 'runner beforeEach',
+ 'inner beforeEach',
+ 'it2',
+ 'inner afterEach',
+ 'runner afterEach',
- "runner beforeEach",
- "inner beforeEach",
- "it",
- "inner afterEach",
- "runner afterEach",
- "inner afterAll",
- "runner afterAll"
+ 'runner beforeEach',
+ 'inner beforeEach',
+ 'it',
+ 'inner afterEach',
+ 'runner afterEach',
+ 'inner afterAll',
+ 'runner afterAll'
];
expect(actions).toEqual(expected);
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute([spec2.id, spec.id]);
});
- it('only runs *Alls once in a focused suite', function(done){
+ it('only runs *Alls once in a focused suite', function(done) {
var actions = [];
env.fdescribe('Suite', function() {
- env.beforeAll(function(){
+ env.beforeAll(function() {
actions.push('beforeAll');
});
env.it('should run beforeAll once', function() {
actions.push('spec');
});
- env.afterAll(function(){
+ env.afterAll(function() {
actions.push('afterAll');
});
});
@@ -411,27 +405,35 @@
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
describe('focused runnables', function() {
it('runs the relevant alls and eachs for each runnable', function(done) {
var actions = [];
- env.beforeAll(function() {actions.push('beforeAll')});
- env.afterAll(function() {actions.push('afterAll')});
- env.beforeEach(function() {actions.push('beforeEach')});
- env.afterEach(function() {actions.push('afterEach')});
+ env.beforeAll(function() {
+ actions.push('beforeAll');
+ });
+ env.afterAll(function() {
+ actions.push('afterAll');
+ });
+ env.beforeEach(function() {
+ actions.push('beforeEach');
+ });
+ env.afterEach(function() {
+ actions.push('afterEach');
+ });
env.fdescribe('a focused suite', function() {
env.it('is run', function() {
- actions.push('spec in fdescribe')
+ actions.push('spec in fdescribe');
});
});
env.describe('an unfocused suite', function() {
env.fit('has a focused spec', function() {
- actions.push('focused spec')
+ actions.push('focused spec');
});
});
@@ -451,19 +453,19 @@
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
- it('focused specs in focused suites cause non-focused siblings to not run', function(done){
+ it('focused specs in focused suites cause non-focused siblings to not run', function(done) {
var actions = [];
env.fdescribe('focused suite', function() {
env.it('unfocused spec', function() {
- actions.push('unfocused spec')
+ actions.push('unfocused spec');
});
env.fit('focused spec', function() {
- actions.push('focused spec')
+ actions.push('focused spec');
});
});
@@ -473,16 +475,16 @@
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
- it('focused suites in focused suites cause non-focused siblings to not run', function(done){
+ it('focused suites in focused suites cause non-focused siblings to not run', function(done) {
var actions = [];
env.fdescribe('focused suite', function() {
env.it('unfocused spec', function() {
- actions.push('unfocused spec')
+ actions.push('unfocused spec');
});
env.fdescribe('inner focused suite', function() {
env.it('inner spec', function() {
@@ -497,7 +499,7 @@
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
@@ -506,7 +508,7 @@
env.fdescribe('focused suite', function() {
env.it('unfocused spec', function() {
- actions.push('unfocused spec')
+ actions.push('unfocused spec');
});
env.describe('inner focused suite', function() {
env.fit('focused spec', function() {
@@ -521,54 +523,54 @@
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
});
it("shouldn't run disabled suites", function(done) {
- var specInADisabledSuite = jasmine.createSpy("specInADisabledSuite"),
- suite = env.describe('A Suite', function() {
- env.xdescribe('with a disabled suite', function(){
- env.it('spec inside a disabled suite', specInADisabledSuite);
+ var specInADisabledSuite = jasmine.createSpy('specInADisabledSuite'),
+ suite = env.describe('A Suite', function() {
+ env.xdescribe('with a disabled suite', function() {
+ env.it('spec inside a disabled suite', specInADisabledSuite);
+ });
});
- });
var assertions = function() {
expect(specInADisabledSuite).not.toHaveBeenCalled();
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
it("shouldn't run before/after functions in disabled suites", function(done) {
- var shouldNotRun = jasmine.createSpy("shouldNotRun"),
- suite = env.xdescribe('A disabled Suite', function() {
- // None of the before/after functions should run.
- env.beforeAll(shouldNotRun);
- env.beforeEach(shouldNotRun);
- env.afterEach(shouldNotRun);
- env.afterAll(shouldNotRun);
+ var shouldNotRun = jasmine.createSpy('shouldNotRun'),
+ suite = env.xdescribe('A disabled Suite', function() {
+ // None of the before/after functions should run.
+ env.beforeAll(shouldNotRun);
+ env.beforeEach(shouldNotRun);
+ env.afterEach(shouldNotRun);
+ env.afterAll(shouldNotRun);
- env.it('spec inside a disabled suite', shouldNotRun);
- });
+ env.it('spec inside a disabled suite', shouldNotRun);
+ });
var assertions = function() {
expect(shouldNotRun).not.toHaveBeenCalled();
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
- it("should allow top level suites to be disabled", function(done) {
- var specInADisabledSuite = jasmine.createSpy("specInADisabledSuite"),
- otherSpec = jasmine.createSpy("otherSpec");
+ it('should allow top level suites to be disabled', function(done) {
+ var specInADisabledSuite = jasmine.createSpy('specInADisabledSuite'),
+ otherSpec = jasmine.createSpy('otherSpec');
env.xdescribe('A disabled suite', function() {
env.it('spec inside a disabled suite', specInADisabledSuite);
@@ -583,28 +585,28 @@
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
- it("should set all pending specs to pending when a suite is run", function(done) {
+ it('should set all pending specs to pending when a suite is run', function(done) {
var pendingSpec,
suite = env.describe('default current suite', function() {
- pendingSpec = env.it("I am a pending spec");
+ pendingSpec = env.it('I am a pending spec');
});
var assertions = function() {
- expect(pendingSpec.status()).toBe("pending");
+ expect(pendingSpec.status()).toBe('pending');
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
- it("should recover gracefully when there are errors in describe functions", function(done) {
+ it('should recover gracefully when there are errors in describe functions', function(done) {
var specs = [],
reporter = jasmine.createSpyObj(['specDone', 'suiteDone', 'jasmineDone']);
@@ -613,35 +615,43 @@
});
reporter.jasmineDone.and.callFake(function() {
- expect(specs).toEqual(['outer1 inner1 should thingy', 'outer1 inner2 should other thingy', 'outer2 should xxx']);
- expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('outer1 inner1', [/inner error/]);
- expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('outer1', [/outer error/]);
+ expect(specs).toEqual([
+ 'outer1 inner1 should thingy',
+ 'outer1 inner2 should other thingy',
+ 'outer2 should xxx'
+ ]);
+ expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
+ 'outer1 inner1',
+ [/inner error/]
+ );
+ expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('outer1', [
+ /outer error/
+ ]);
done();
});
expect(function() {
- env.describe("outer1", function() {
- env.describe("inner1", function() {
- env.it("should thingy", function() {
+ env.describe('outer1', function() {
+ env.describe('inner1', function() {
+ env.it('should thingy', function() {
this.expect(true).toEqual(true);
});
- throw new Error("inner error");
+ throw new Error('inner error');
});
- env.describe("inner2", function() {
- env.it("should other thingy", function() {
+ env.describe('inner2', function() {
+ env.it('should other thingy', function() {
this.expect(true).toEqual(true);
});
});
- throw new Error("outer error");
-
+ throw new Error('outer error');
});
}).not.toThrow();
- env.describe("outer2", function() {
- env.it("should xxx", function() {
+ env.describe('outer2', function() {
+ env.it('should xxx', function() {
this.expect(true).toEqual(true);
});
});
@@ -650,27 +660,29 @@
env.execute();
});
- it("re-enters suites that have no *Alls", function(done) {
+ it('re-enters suites that have no *Alls', function(done) {
var actions = [],
- spec1, spec2, spec3;
+ spec1,
+ spec2,
+ spec3;
- env.describe("top", function() {
- spec1 = env.it("spec1", function() {
- actions.push("spec1");
+ env.describe('top', function() {
+ spec1 = env.it('spec1', function() {
+ actions.push('spec1');
});
- spec2 = env.it("spec2", function() {
- actions.push("spec2");
+ spec2 = env.it('spec2', function() {
+ actions.push('spec2');
});
});
- spec3 = env.it("spec3", function() {
- actions.push("spec3");
+ spec3 = env.it('spec3', function() {
+ actions.push('spec3');
});
env.addReporter({
jasmineDone: function() {
- expect(actions).toEqual(["spec2", "spec3", "spec1"]);
+ expect(actions).toEqual(['spec2', 'spec3', 'spec1']);
done();
}
});
@@ -678,24 +690,26 @@
env.execute([spec2.id, spec3.id, spec1.id]);
});
- it("refuses to re-enter suites with a beforeAll", function() {
+ it('refuses to re-enter suites with a beforeAll', function() {
var actions = [],
- spec1, spec2, spec3;
+ spec1,
+ spec2,
+ spec3;
- env.describe("top", function() {
+ env.describe('top', function() {
env.beforeAll(function() {});
- spec1 = env.it("spec1", function() {
- actions.push("spec1");
+ spec1 = env.it('spec1', function() {
+ actions.push('spec1');
});
- spec2 = env.it("spec2", function() {
- actions.push("spec2");
+ spec2 = env.it('spec2', function() {
+ actions.push('spec2');
});
});
- spec3 = env.it("spec3", function() {
- actions.push("spec3");
+ spec3 = env.it('spec3', function() {
+ actions.push('spec3');
});
env.addReporter({
@@ -710,24 +724,26 @@
}).toThrowError(/beforeAll/);
});
- it("refuses to re-enter suites with a afterAll", function() {
+ it('refuses to re-enter suites with a afterAll', function() {
var actions = [],
- spec1, spec2, spec3;
+ spec1,
+ spec2,
+ spec3;
- env.describe("top", function() {
+ env.describe('top', function() {
env.afterAll(function() {});
- spec1 = env.it("spec1", function() {
- actions.push("spec1");
+ spec1 = env.it('spec1', function() {
+ actions.push('spec1');
});
- spec2 = env.it("spec2", function() {
- actions.push("spec2");
+ spec2 = env.it('spec2', function() {
+ actions.push('spec2');
});
});
- spec3 = env.it("spec3", function() {
- actions.push("spec3");
+ spec3 = env.it('spec3', function() {
+ actions.push('spec3');
});
env.addReporter({
@@ -742,15 +758,15 @@
}).toThrowError(/afterAll/);
});
- it("should run the tests in a consistent order when a seed is supplied", function(done) {
+ it('should run the tests in a consistent order when a seed is supplied', function(done) {
var actions = [];
- env.configure({random: true, seed: '123456'});
+ env.configure({ random: true, seed: '123456' });
- env.beforeEach(function () {
+ env.beforeEach(function() {
actions.push('topSuite beforeEach');
});
- env.afterEach(function () {
+ env.afterEach(function() {
actions.push('topSuite afterEach');
});
@@ -834,19 +850,19 @@
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
- describe("When throwOnExpectationFailure is set", function() {
- it("skips to cleanup functions after an error", function(done) {
+ describe('When throwOnExpectationFailure is set', function() {
+ it('skips to cleanup functions after an error', function(done) {
var actions = [];
env.describe('Something', function() {
env.beforeEach(function() {
actions.push('outer beforeEach');
- throw new Error("error");
+ throw new Error('error');
});
env.afterEach(function() {
@@ -862,13 +878,13 @@
actions.push('inner afterEach');
});
- env.it('does it' , function() {
+ env.it('does it', function() {
actions.push('inner it');
});
});
});
- env.configure({oneFailurePerSpec: true});
+ env.configure({ oneFailurePerSpec: true });
var assertions = function() {
expect(actions).toEqual([
@@ -879,12 +895,12 @@
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
- it("skips to cleanup functions after done.fail is called", function(done) {
+ it('skips to cleanup functions after done.fail is called', function(done) {
var actions = [];
env.describe('Something', function() {
@@ -898,27 +914,24 @@
actions.push('afterEach');
});
- env.it('does it' , function() {
+ env.it('does it', function() {
actions.push('it');
});
});
- env.configure({oneFailurePerSpec: true});
+ env.configure({ oneFailurePerSpec: true });
var assertions = function() {
- expect(actions).toEqual([
- 'beforeEach',
- 'afterEach'
- ]);
+ expect(actions).toEqual(['beforeEach', 'afterEach']);
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
- it("skips to cleanup functions when an async function times out", function(done) {
+ it('skips to cleanup functions when an async function times out', function(done) {
var actions = [];
env.describe('Something', function() {
@@ -930,27 +943,24 @@
actions.push('afterEach');
});
- env.it('does it' , function() {
+ env.it('does it', function() {
actions.push('it');
});
});
- env.configure({oneFailurePerSpec: true});
+ env.configure({ oneFailurePerSpec: true });
var assertions = function() {
- expect(actions).toEqual([
- 'beforeEach',
- 'afterEach'
- ]);
+ expect(actions).toEqual(['beforeEach', 'afterEach']);
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
- it("skips to cleanup functions after an error with deprecations", function(done) {
+ it('skips to cleanup functions after an error with deprecations', function(done) {
var actions = [];
spyOn(env, 'deprecated');
@@ -958,7 +968,7 @@
env.describe('Something', function() {
env.beforeEach(function() {
actions.push('outer beforeEach');
- throw new Error("error");
+ throw new Error('error');
});
env.afterEach(function() {
@@ -974,7 +984,7 @@
actions.push('inner afterEach');
});
- env.it('does it' , function() {
+ env.it('does it', function() {
actions.push('inner it');
});
});
@@ -992,12 +1002,12 @@
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
- it("skips to cleanup functions after done.fail is called with deprecations", function(done) {
+ it('skips to cleanup functions after done.fail is called with deprecations', function(done) {
var actions = [];
spyOn(env, 'deprecated');
@@ -1013,7 +1023,7 @@
actions.push('afterEach');
});
- env.it('does it' , function() {
+ env.it('does it', function() {
actions.push('it');
});
});
@@ -1021,20 +1031,17 @@
env.throwOnExpectationFailure(true);
var assertions = function() {
- expect(actions).toEqual([
- 'beforeEach',
- 'afterEach'
- ]);
+ expect(actions).toEqual(['beforeEach', 'afterEach']);
expect(env.deprecated).toHaveBeenCalled();
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
- it("skips to cleanup functions when an async function times out with deprecations", function(done) {
+ it('skips to cleanup functions when an async function times out with deprecations', function(done) {
var actions = [];
spyOn(env, 'deprecated');
@@ -1048,7 +1055,7 @@
actions.push('afterEach');
});
- env.it('does it' , function() {
+ env.it('does it', function() {
actions.push('it');
});
});
@@ -1056,22 +1063,19 @@
env.throwOnExpectationFailure(true);
var assertions = function() {
- expect(actions).toEqual([
- 'beforeEach',
- 'afterEach'
- ]);
+ expect(actions).toEqual(['beforeEach', 'afterEach']);
expect(env.deprecated).toHaveBeenCalled();
done();
};
- env.addReporter({jasmineDone: assertions});
+ env.addReporter({ jasmineDone: assertions });
env.execute();
});
});
- describe("when stopOnSpecFailure is on", function() {
- it("does not run further specs when one fails", function(done) {
+ describe('when stopOnSpecFailure is on', function() {
+ it('does not run further specs when one fails', function(done) {
var actions = [];
env.describe('wrapper', function() {
@@ -1087,7 +1091,7 @@
});
});
- env.configure({random: false, failFast: true});
+ env.configure({ random: false, failFast: true });
var assertions = function() {
expect(actions).toEqual(['fails']);
@@ -1098,7 +1102,7 @@
env.execute();
});
- it("does not run further specs when one fails when configured with deprecated option", function(done) {
+ it('does not run further specs when one fails when configured with deprecated option', function(done) {
var actions = [];
spyOn(env, 'deprecated');
@@ -1116,7 +1120,7 @@
});
});
- env.configure({random: false});
+ env.configure({ random: false });
env.stopOnSpecFailure(true);
var assertions = function() {
diff --git a/spec/core/matchers/DiffBuilderSpec.js b/spec/core/matchers/DiffBuilderSpec.js
index 01220ce..d1a3d88 100644
--- a/spec/core/matchers/DiffBuilderSpec.js
+++ b/spec/core/matchers/DiffBuilderSpec.js
@@ -1,132 +1,159 @@
-describe("DiffBuilder", function () {
- it("records the actual and expected objects", function () {
+describe('DiffBuilder', function() {
+ it('records the actual and expected objects', function() {
var diffBuilder = jasmineUnderTest.DiffBuilder();
- diffBuilder.setRoots({x: 'actual'}, {x: 'expected'});
+ diffBuilder.setRoots({ x: 'actual' }, { x: 'expected' });
diffBuilder.recordMismatch();
- expect(diffBuilder.getMessage()).toEqual("Expected Object({ x: 'actual' }) to equal Object({ x: 'expected' }).");
+ expect(diffBuilder.getMessage()).toEqual(
+ "Expected Object({ x: 'actual' }) to equal Object({ x: 'expected' })."
+ );
});
- it("prints the path at which the difference was found", function () {
+ it('prints the path at which the difference was found', function() {
var diffBuilder = jasmineUnderTest.DiffBuilder();
- diffBuilder.setRoots({foo: {x: 'actual'}}, {foo: {x: 'expected'}});
+ diffBuilder.setRoots({ foo: { x: 'actual' } }, { foo: { x: 'expected' } });
- diffBuilder.withPath('foo', function () {
+ diffBuilder.withPath('foo', function() {
diffBuilder.recordMismatch();
});
- expect(diffBuilder.getMessage()).toEqual("Expected $.foo = Object({ x: 'actual' }) to equal Object({ x: 'expected' }).");
+ expect(diffBuilder.getMessage()).toEqual(
+ "Expected $.foo = Object({ x: 'actual' }) to equal Object({ x: 'expected' })."
+ );
});
- it("prints multiple messages, separated by newlines", function () {
+ it('prints multiple messages, separated by newlines', function() {
var diffBuilder = jasmineUnderTest.DiffBuilder();
- diffBuilder.setRoots({foo: 1, bar: 3}, {foo: 2, bar: 4});
+ diffBuilder.setRoots({ foo: 1, bar: 3 }, { foo: 2, bar: 4 });
- diffBuilder.withPath('foo', function () {
+ diffBuilder.withPath('foo', function() {
diffBuilder.recordMismatch();
});
- diffBuilder.withPath('bar', function () {
+ diffBuilder.withPath('bar', function() {
diffBuilder.recordMismatch();
});
var message =
- "Expected $.foo = 1 to equal 2.\n" +
- "Expected $.bar = 3 to equal 4.";
+ 'Expected $.foo = 1 to equal 2.\n' + 'Expected $.bar = 3 to equal 4.';
expect(diffBuilder.getMessage()).toEqual(message);
});
- it("allows customization of the message", function () {
+ it('allows customization of the message', function() {
var diffBuilder = jasmineUnderTest.DiffBuilder();
- diffBuilder.setRoots({x: 'bar'}, {x: 'foo'});
+ diffBuilder.setRoots({ x: 'bar' }, { x: 'foo' });
function darthVaderFormatter(actual, expected, path) {
- return "I find your lack of " + expected + " disturbing. (was " + actual + ", at " + path + ")"
+ return (
+ 'I find your lack of ' +
+ expected +
+ ' disturbing. (was ' +
+ actual +
+ ', at ' +
+ path +
+ ')'
+ );
}
- diffBuilder.withPath('x', function () {
+ diffBuilder.withPath('x', function() {
diffBuilder.recordMismatch(darthVaderFormatter);
});
- expect(diffBuilder.getMessage()).toEqual("I find your lack of foo disturbing. (was bar, at $.x)");
+ expect(diffBuilder.getMessage()).toEqual(
+ 'I find your lack of foo disturbing. (was bar, at $.x)'
+ );
});
- it("uses the injected pretty-printer", function () {
- var prettyPrinter = function (val) {
+ it('uses the injected pretty-printer', function() {
+ var prettyPrinter = function(val) {
return '|' + val + '|';
},
- diffBuilder = jasmineUnderTest.DiffBuilder({prettyPrinter: prettyPrinter});
- prettyPrinter.customFormat_ = function () {
- };
+ diffBuilder = jasmineUnderTest.DiffBuilder({
+ prettyPrinter: prettyPrinter
+ });
+ prettyPrinter.customFormat_ = function() {};
- diffBuilder.setRoots({foo: 'actual'}, {foo: 'expected'});
- diffBuilder.withPath('foo', function () {
+ diffBuilder.setRoots({ foo: 'actual' }, { foo: 'expected' });
+ diffBuilder.withPath('foo', function() {
diffBuilder.recordMismatch();
});
- expect(diffBuilder.getMessage()).toEqual("Expected $.foo = |actual| to equal |expected|.");
+ expect(diffBuilder.getMessage()).toEqual(
+ 'Expected $.foo = |actual| to equal |expected|.'
+ );
});
- it("passes the injected pretty-printer to the diff formatter", function () {
+ it('passes the injected pretty-printer to the diff formatter', function() {
var diffFormatter = jasmine.createSpy('diffFormatter'),
- prettyPrinter = function () {
- },
- diffBuilder = jasmineUnderTest.DiffBuilder({prettyPrinter: prettyPrinter});
- prettyPrinter.customFormat_ = function () {
- };
+ prettyPrinter = function() {},
+ diffBuilder = jasmineUnderTest.DiffBuilder({
+ prettyPrinter: prettyPrinter
+ });
+ prettyPrinter.customFormat_ = function() {};
- diffBuilder.setRoots({x: 'bar'}, {x: 'foo'});
- diffBuilder.withPath('x', function () {
+ diffBuilder.setRoots({ x: 'bar' }, { x: 'foo' });
+ diffBuilder.withPath('x', function() {
diffBuilder.recordMismatch(diffFormatter);
});
diffBuilder.getMessage();
- expect(diffFormatter).toHaveBeenCalledWith('bar', 'foo', jasmine.anything(), prettyPrinter);
+ expect(diffFormatter).toHaveBeenCalledWith(
+ 'bar',
+ 'foo',
+ jasmine.anything(),
+ prettyPrinter
+ );
});
- it("uses custom object formatters on leaf nodes", function() {
+ it('uses custom object formatters on leaf nodes', function() {
var formatter = function(x) {
if (typeof x === 'number') {
return '[number:' + x + ']';
}
};
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]);
- var diffBuilder = new jasmineUnderTest.DiffBuilder({prettyPrinter: prettyPrinter});
+ var diffBuilder = new jasmineUnderTest.DiffBuilder({
+ prettyPrinter: prettyPrinter
+ });
diffBuilder.setRoots(5, 4);
diffBuilder.recordMismatch();
- expect(diffBuilder.getMessage()).toEqual('Expected [number:5] to equal [number:4].');
+ expect(diffBuilder.getMessage()).toEqual(
+ 'Expected [number:5] to equal [number:4].'
+ );
});
-
- it("uses custom object formatters on non leaf nodes", function () {
- var formatter = function (x) {
+ it('uses custom object formatters on non leaf nodes', function() {
+ var formatter = function(x) {
if (x.hasOwnProperty('a')) {
return '[thing with a=' + x.a + ', b=' + JSON.stringify(x.b) + ']';
}
};
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]);
- var diffBuilder = new jasmineUnderTest.DiffBuilder({prettyPrinter: prettyPrinter});
- var expectedMsg = 'Expected $[0].foo = [thing with a=1, b={"x":42}] to equal [thing with a=1, b={"x":43}].\n' +
+ var diffBuilder = new jasmineUnderTest.DiffBuilder({
+ prettyPrinter: prettyPrinter
+ });
+ var expectedMsg =
+ 'Expected $[0].foo = [thing with a=1, b={"x":42}] to equal [thing with a=1, b={"x":43}].\n' +
"Expected $[0].bar = 'yes' to equal 'no'.";
diffBuilder.setRoots(
- [{foo: {a: 1, b: {x: 42}}, bar: 'yes'}],
- [{foo: {a: 1, b: {x: 43}}, bar: 'no'}]
+ [{ foo: { a: 1, b: { x: 42 } }, bar: 'yes' }],
+ [{ foo: { a: 1, b: { x: 43 } }, bar: 'no' }]
);
- diffBuilder.withPath(0, function () {
- diffBuilder.withPath('foo', function () {
- diffBuilder.withPath('b', function () {
- diffBuilder.withPath('x', function () {
+ diffBuilder.withPath(0, function() {
+ diffBuilder.withPath('foo', function() {
+ diffBuilder.withPath('b', function() {
+ diffBuilder.withPath('x', function() {
diffBuilder.recordMismatch();
});
});
});
- diffBuilder.withPath('bar', function () {
+ diffBuilder.withPath('bar', function() {
diffBuilder.recordMismatch();
});
});
@@ -136,14 +163,16 @@
it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ at the root', function() {
var prettyPrinter = jasmineUnderTest.makePrettyPrinter([]),
- diffBuilder = new jasmineUnderTest.DiffBuilder({prettyPrinter: prettyPrinter}),
- expectedMsg = 'Expected $.foo = 1 to equal 2.\n' +
- "Expected $.baz = undefined to equal 3.";
-
+ diffBuilder = new jasmineUnderTest.DiffBuilder({
+ prettyPrinter: prettyPrinter
+ }),
+ expectedMsg =
+ 'Expected $.foo = 1 to equal 2.\n' +
+ 'Expected $.baz = undefined to equal 3.';
diffBuilder.setRoots(
- {foo: 1, bar: 2},
- jasmine.objectContaining({foo: 2, baz: 3})
+ { foo: 1, bar: 2 },
+ jasmine.objectContaining({ foo: 2, baz: 3 })
);
diffBuilder.withPath('foo', function() {
@@ -158,21 +187,23 @@
it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ below the root', function() {
var prettyPrinter = jasmineUnderTest.makePrettyPrinter([]),
- diffBuilder = new jasmineUnderTest.DiffBuilder({prettyPrinter: prettyPrinter}),
- expectedMsg = 'Expected $.x.foo = 1 to equal 2.\n' +
- "Expected $.x.baz = undefined to equal 3.";
-
+ diffBuilder = new jasmineUnderTest.DiffBuilder({
+ prettyPrinter: prettyPrinter
+ }),
+ expectedMsg =
+ 'Expected $.x.foo = 1 to equal 2.\n' +
+ 'Expected $.x.baz = undefined to equal 3.';
diffBuilder.setRoots(
- {x: {foo: 1, bar: 2}},
- {x: jasmine.objectContaining({foo: 2, baz: 3})}
+ { x: { foo: 1, bar: 2 } },
+ { x: jasmine.objectContaining({ foo: 2, baz: 3 }) }
);
diffBuilder.withPath('x', function() {
- diffBuilder.withPath('foo', function () {
+ diffBuilder.withPath('foo', function() {
diffBuilder.recordMismatch();
});
- diffBuilder.withPath('baz', function () {
+ diffBuilder.withPath('baz', function() {
diffBuilder.recordMismatch();
});
});
diff --git a/spec/core/matchers/MismatchTreeSpec.js b/spec/core/matchers/MismatchTreeSpec.js
index ea053eb..8a158df 100644
--- a/spec/core/matchers/MismatchTreeSpec.js
+++ b/spec/core/matchers/MismatchTreeSpec.js
@@ -1,15 +1,15 @@
-describe('MismatchTree', function () {
- describe('#add', function () {
- describe('When the path is empty', function () {
- it('flags the root node as mismatched', function () {
+describe('MismatchTree', function() {
+ describe('#add', function() {
+ describe('When the path is empty', function() {
+ it('flags the root node as mismatched', function() {
var tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath([]));
expect(tree.isMismatch).toBe(true);
});
});
- describe('When the path is not empty', function () {
- it('flags the node as mismatched', function () {
+ describe('When the path is not empty', function() {
+ it('flags the node as mismatched', function() {
var tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']));
@@ -17,7 +17,7 @@
expect(tree.child('a').child('b').isMismatch).toBe(true);
});
- it('does not flag ancestors as mismatched', function () {
+ it('does not flag ancestors as mismatched', function() {
var tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']));
@@ -27,7 +27,7 @@
});
});
- it('stores the formatter on only the target node', function () {
+ it('stores the formatter on only the target node', function() {
var tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']), formatter);
@@ -37,7 +37,7 @@
expect(tree.child('a').child('b').formatter).toBe(formatter);
});
- it('stores the path to the node', function () {
+ it('stores the path to the node', function() {
var tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']), formatter);
@@ -46,8 +46,8 @@
});
});
- describe('#traverse', function () {
- it('calls the callback for all nodes that are or contain mismatches', function () {
+ describe('#traverse', function() {
+ it('calls the callback for all nodes that are or contain mismatches', function() {
var tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']), formatter);
tree.add(new jasmineUnderTest.ObjectPath(['c']));
@@ -56,20 +56,28 @@
tree.traverse(visit);
expect(visit).toHaveBeenCalledWith(
- new jasmineUnderTest.ObjectPath([]), false, undefined
+ new jasmineUnderTest.ObjectPath([]),
+ false,
+ undefined
);
expect(visit).toHaveBeenCalledWith(
- new jasmineUnderTest.ObjectPath(['a']), false, undefined
+ new jasmineUnderTest.ObjectPath(['a']),
+ false,
+ undefined
);
expect(visit).toHaveBeenCalledWith(
- new jasmineUnderTest.ObjectPath(['a', 'b']), true, formatter
+ new jasmineUnderTest.ObjectPath(['a', 'b']),
+ true,
+ formatter
);
expect(visit).toHaveBeenCalledWith(
- new jasmineUnderTest.ObjectPath(['c']), true, undefined
+ new jasmineUnderTest.ObjectPath(['c']),
+ true,
+ undefined
);
});
- it('does not call the callback if there are no mismatches', function () {
+ it('does not call the callback if there are no mismatches', function() {
var tree = new jasmineUnderTest.MismatchTree();
var visit = jasmine.createSpy('visit');
@@ -78,12 +86,12 @@
expect(visit).not.toHaveBeenCalled();
});
- it('visits parents before children', function () {
+ it('visits parents before children', function() {
var tree = new jasmineUnderTest.MismatchTree();
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']));
var visited = [];
- tree.traverse(function (path) {
+ tree.traverse(function(path) {
visited.push(path);
return true;
});
@@ -101,7 +109,7 @@
tree.add(new jasmineUnderTest.ObjectPath([1]));
var visited = [];
- tree.traverse(function (path) {
+ tree.traverse(function(path) {
visited.push(path);
return true;
});
@@ -118,7 +126,7 @@
tree.add(new jasmineUnderTest.ObjectPath(['a', 'b']));
var visited = [];
- tree.traverse(function (path) {
+ tree.traverse(function(path) {
visited.push(path);
return path.depth() === 0;
});
@@ -130,7 +138,5 @@
});
});
- function formatter() {
- }
-
+ function formatter() {}
});
diff --git a/spec/core/matchers/NullDiffBuilderSpec.js b/spec/core/matchers/NullDiffBuilderSpec.js
index 3333776..fa9ed29 100644
--- a/spec/core/matchers/NullDiffBuilderSpec.js
+++ b/spec/core/matchers/NullDiffBuilderSpec.js
@@ -1,8 +1,7 @@
-describe('NullDiffBuilder', function () {
- it('responds to withPath() by calling the passed function', function () {
+describe('NullDiffBuilder', function() {
+ it('responds to withPath() by calling the passed function', function() {
var spy = jasmine.createSpy('callback');
jasmineUnderTest.NullDiffBuilder().withPath('does not matter', spy);
expect(spy).toHaveBeenCalled();
});
-
});
diff --git a/spec/core/matchers/async/toBePendingSpec.js b/spec/core/matchers/async/toBePendingSpec.js
index 285414f..0b78d8c 100644
--- a/spec/core/matchers/async/toBePendingSpec.js
+++ b/spec/core/matchers/async/toBePendingSpec.js
@@ -8,7 +8,7 @@
actual = new Promise(function() {});
return matcher.compare(actual).then(function(result) {
- expect(result).toEqual(jasmine.objectContaining({pass: true}));
+ expect(result).toEqual(jasmine.objectContaining({ pass: true }));
});
});
@@ -20,7 +20,7 @@
actual = Promise.resolve();
return matcher.compare(actual).then(function(result) {
- expect(result).toEqual(jasmine.objectContaining({pass: false}));
+ expect(result).toEqual(jasmine.objectContaining({ pass: false }));
});
});
@@ -32,21 +32,19 @@
actual = Promise.reject(new Error('promise was rejected'));
return matcher.compare(actual).then(function(result) {
- expect(result).toEqual(jasmine.objectContaining({pass: false}));
+ expect(result).toEqual(jasmine.objectContaining({ pass: false }));
});
});
it('fails if actual is not a promise', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
- matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
- actual = 'not a promise';
+ matcher = jasmineUnderTest.asyncMatchers.toBePending(matchersUtil),
+ actual = 'not a promise';
function f() {
return matcher.compare(actual);
}
- expect(f).toThrowError(
- 'Expected toBePending to be called on a promise.'
- );
+ expect(f).toThrowError('Expected toBePending to be called on a promise.');
});
});
diff --git a/spec/core/matchers/async/toBeRejectedSpec.js b/spec/core/matchers/async/toBeRejectedSpec.js
index 6ecf9eb..c1ea377 100644
--- a/spec/core/matchers/async/toBeRejectedSpec.js
+++ b/spec/core/matchers/async/toBeRejectedSpec.js
@@ -8,7 +8,7 @@
actual = Promise.reject('AsyncExpectationSpec rejection');
return matcher.compare(actual).then(function(result) {
- expect(result).toEqual(jasmine.objectContaining({pass: true}));
+ expect(result).toEqual(jasmine.objectContaining({ pass: true }));
});
});
@@ -20,7 +20,7 @@
actual = Promise.resolve();
return matcher.compare(actual).then(function(result) {
- expect(result).toEqual(jasmine.objectContaining({pass: false}));
+ expect(result).toEqual(jasmine.objectContaining({ pass: false }));
});
});
@@ -33,8 +33,6 @@
return matcher.compare(actual);
}
- expect(f).toThrowError(
- 'Expected toBeRejected to be called on a promise.'
- );
+ expect(f).toThrowError('Expected toBeRejected to be called on a promise.');
});
});
diff --git a/spec/core/matchers/async/toBeRejectedWithErrorSpec.js b/spec/core/matchers/async/toBeRejectedWithErrorSpec.js
index d09a05f..d7d3f65 100644
--- a/spec/core/matchers/async/toBeRejectedWithErrorSpec.js
+++ b/spec/core/matchers/async/toBeRejectedWithErrorSpec.js
@@ -1,174 +1,253 @@
/* eslint-disable compat/compat */
-describe('#toBeRejectedWithError', function () {
- it('passes when Error type matches', function () {
+describe('#toBeRejectedWithError', function() {
+ it('passes when Error type matches', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
- matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
+ matchersUtil
+ ),
actual = Promise.reject(new TypeError('foo'));
- return matcher.compare(actual, TypeError).then(function (result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: true,
- message: 'Expected a promise not to be rejected with TypeError, but it was.'
- }));
+ return matcher.compare(actual, TypeError).then(function(result) {
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: true,
+ message:
+ 'Expected a promise not to be rejected with TypeError, but it was.'
+ })
+ );
});
});
- it('passes when Error type and message matches', function () {
+ it('passes when Error type and message matches', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
- matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
+ matchersUtil
+ ),
actual = Promise.reject(new TypeError('foo'));
- return matcher.compare(actual, TypeError, 'foo').then(function (result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: true,
- message: 'Expected a promise not to be rejected with TypeError: \'foo\', but it was.'
- }));
+ return matcher.compare(actual, TypeError, 'foo').then(function(result) {
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: true,
+ message:
+ "Expected a promise not to be rejected with TypeError: 'foo', but it was."
+ })
+ );
});
});
it('passes when Error matches and is exactly Error', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
- matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
+ matchersUtil
+ ),
actual = Promise.reject(new Error());
- return matcher.compare(actual, Error).then(function (result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: true,
- message: 'Expected a promise not to be rejected with Error, but it was.'
- }));
+ return matcher.compare(actual, Error).then(function(result) {
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: true,
+ message:
+ 'Expected a promise not to be rejected with Error, but it was.'
+ })
+ );
});
-
});
- it('passes when Error message matches a string', function () {
+ it('passes when Error message matches a string', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
- matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
+ matchersUtil
+ ),
actual = Promise.reject(new Error('foo'));
- return matcher.compare(actual, 'foo').then(function (result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: true,
- message: 'Expected a promise not to be rejected with Error: \'foo\', but it was.'
- }));
+ return matcher.compare(actual, 'foo').then(function(result) {
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: true,
+ message:
+ "Expected a promise not to be rejected with Error: 'foo', but it was."
+ })
+ );
});
});
- it('passes when Error message matches a RegExp', function () {
+ it('passes when Error message matches a RegExp', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
- matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
+ matchersUtil
+ ),
actual = Promise.reject(new Error('foo'));
- return matcher.compare(actual, /foo/).then(function (result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: true,
- message: 'Expected a promise not to be rejected with Error: /foo/, but it was.'
- }));
+ return matcher.compare(actual, /foo/).then(function(result) {
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: true,
+ message:
+ 'Expected a promise not to be rejected with Error: /foo/, but it was.'
+ })
+ );
});
});
- it('passes when Error message is empty', function () {
+ it('passes when Error message is empty', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
- matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
+ matchersUtil
+ ),
actual = Promise.reject(new Error());
- return matcher.compare(actual, '').then(function (result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: true,
- message: 'Expected a promise not to be rejected with Error: \'\', but it was.'
- }));
+ return matcher.compare(actual, '').then(function(result) {
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: true,
+ message:
+ "Expected a promise not to be rejected with Error: '', but it was."
+ })
+ );
});
});
- it('passes when no arguments', function () {
+ it('passes when no arguments', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
- matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
+ matchersUtil
+ ),
actual = Promise.reject(new Error());
- return matcher.compare(actual, void 0).then(function (result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: true,
- message: 'Expected a promise not to be rejected with Error, but it was.'
- }));
+ return matcher.compare(actual, void 0).then(function(result) {
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: true,
+ message:
+ 'Expected a promise not to be rejected with Error, but it was.'
+ })
+ );
});
});
- it('fails when resolved', function () {
+ it('fails when resolved', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
- matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
+ matchersUtil
+ ),
actual = Promise.resolve(new Error('foo'));
- return matcher.compare(actual, 'foo').then(function (result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: false,
- message: 'Expected a promise to be rejected but it was resolved.'
- }));
+ return matcher.compare(actual, 'foo').then(function(result) {
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: false,
+ message: 'Expected a promise to be rejected but it was resolved.'
+ })
+ );
});
});
- it('fails when rejected with non Error type', function () {
+ it('fails when rejected with non Error type', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
- matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
+ matchersUtil
+ ),
actual = Promise.reject('foo');
- return matcher.compare(actual, 'foo').then(function (result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: false,
- message: 'Expected a promise to be rejected with Error: \'foo\' but it was rejected with \'foo\'.'
- }));
+ return matcher.compare(actual, 'foo').then(function(result) {
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: false,
+ message:
+ "Expected a promise to be rejected with Error: 'foo' but it was rejected with 'foo'."
+ })
+ );
});
});
- it('fails when Error type mismatches', function () {
+ it('fails when Error type mismatches', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
- matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
+ matchersUtil
+ ),
actual = Promise.reject(new Error('foo'));
- return matcher.compare(actual, TypeError, 'foo').then(function (result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: false,
- message: 'Expected a promise to be rejected with TypeError: \'foo\' but it was rejected with type Error.'
- }));
+ return matcher.compare(actual, TypeError, 'foo').then(function(result) {
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: false,
+ message:
+ "Expected a promise to be rejected with TypeError: 'foo' but it was rejected with type Error."
+ })
+ );
});
});
- it('fails when Error message mismatches', function () {
+ it('fails when Error message mismatches', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
- matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
+ matchersUtil
+ ),
actual = Promise.reject(new Error('foo'));
- return matcher.compare(actual, 'bar').then(function (result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: false,
- message: 'Expected a promise to be rejected with Error: \'bar\' but it was rejected with Error: foo.'
- }));
+ return matcher.compare(actual, 'bar').then(function(result) {
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: false,
+ message:
+ "Expected a promise to be rejected with Error: 'bar' but it was rejected with Error: foo."
+ })
+ );
});
});
it('fails if actual is not a promise', function() {
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
- matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
+ matchersUtil
+ ),
actual = 'not a promise';
function f() {
diff --git a/spec/core/matchers/async/toBeRejectedWithSpec.js b/spec/core/matchers/async/toBeRejectedWithSpec.js
index 69003c5..9c66393 100644
--- a/spec/core/matchers/async/toBeRejectedWithSpec.js
+++ b/spec/core/matchers/async/toBeRejectedWithSpec.js
@@ -1,74 +1,91 @@
/* eslint-disable compat/compat */
-describe('#toBeRejectedWith', function () {
- it('should return true if the promise is rejected with the expected value', function () {
+describe('#toBeRejectedWith', function() {
+ it('should return true if the promise is rejected with the expected value', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
- actual = Promise.reject({error: 'PEBCAK'});
+ actual = Promise.reject({ error: 'PEBCAK' });
- return matcher.compare(actual, {error: 'PEBCAK'}).then(function (result) {
+ return matcher.compare(actual, { error: 'PEBCAK' }).then(function(result) {
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
});
});
- it('should fail if the promise resolves', function () {
+ it('should fail if the promise resolves', function() {
jasmine.getEnv().requirePromises();
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
actual = Promise.resolve();
- return matcher.compare(actual, '').then(function (result) {
+ return matcher.compare(actual, '').then(function(result) {
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
});
});
- it('should fail if the promise is rejected with a different value', function () {
+ it('should fail if the promise is rejected with a different value', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
actual = Promise.reject('A Bad Apple');
- return matcher.compare(actual, 'Some Cool Thing').then(function (result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: false,
- message: "Expected a promise to be rejected with 'Some Cool Thing' but it was rejected with 'A Bad Apple'.",
- }));
+ return matcher.compare(actual, 'Some Cool Thing').then(function(result) {
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: false,
+ message:
+ "Expected a promise to be rejected with 'Some Cool Thing' but it was rejected with 'A Bad Apple'."
+ })
+ );
});
});
- it('should build its error correctly when negated', function () {
+ it('should build its error correctly when negated', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
actual = Promise.reject(true);
- return matcher.compare(actual, true).then(function (result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: true,
- message: 'Expected a promise not to be rejected with true.'
- }));
+ return matcher.compare(actual, true).then(function(result) {
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: true,
+ message: 'Expected a promise not to be rejected with true.'
+ })
+ );
});
});
- it('should support custom equality testers', function () {
+ it('should support custom equality testers', function() {
jasmine.getEnv().requirePromises();
- var customEqualityTesters = [function() { return true; }],
- matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: customEqualityTesters}),
+ var customEqualityTesters = [
+ function() {
+ return true;
+ }
+ ],
+ matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: customEqualityTesters
+ }),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
actual = Promise.reject('actual');
return matcher.compare(actual, 'expected').then(function(result) {
- expect(result).toEqual(jasmine.objectContaining({pass: true}));
+ expect(result).toEqual(jasmine.objectContaining({ pass: true }));
});
});
it('fails if actual is not a promise', function() {
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(matchersUtil),
actual = 'not a promise';
diff --git a/spec/core/matchers/async/toBeResolvedSpec.js b/spec/core/matchers/async/toBeResolvedSpec.js
index 8dbff1c..668b1bb 100644
--- a/spec/core/matchers/async/toBeResolvedSpec.js
+++ b/spec/core/matchers/async/toBeResolvedSpec.js
@@ -8,7 +8,7 @@
actual = Promise.resolve();
return matcher.compare(actual).then(function(result) {
- expect(result).toEqual(jasmine.objectContaining({pass: true}));
+ expect(result).toEqual(jasmine.objectContaining({ pass: true }));
});
});
@@ -20,7 +20,7 @@
actual = Promise.reject('AsyncExpectationSpec rejection');
return matcher.compare(actual).then(function(result) {
- expect(result).toEqual(jasmine.objectContaining({pass: false}));
+ expect(result).toEqual(jasmine.objectContaining({ pass: false }));
});
});
@@ -33,8 +33,6 @@
return matcher.compare(actual);
}
- expect(f).toThrowError(
- 'Expected toBeResolved to be called on a promise.'
- );
+ expect(f).toThrowError('Expected toBeResolved to be called on a promise.');
});
});
diff --git a/spec/core/matchers/async/toBeResolvedToSpec.js b/spec/core/matchers/async/toBeResolvedToSpec.js
index ee57abe..459e93a 100644
--- a/spec/core/matchers/async/toBeResolvedToSpec.js
+++ b/spec/core/matchers/async/toBeResolvedToSpec.js
@@ -5,62 +5,80 @@
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
- actual = Promise.resolve({foo: 42});
+ actual = Promise.resolve({ foo: 42 });
- return matcher.compare(actual, {foo: 42}).then(function(result) {
- expect(result).toEqual(jasmine.objectContaining({pass: true}));
+ return matcher.compare(actual, { foo: 42 }).then(function(result) {
+ expect(result).toEqual(jasmine.objectContaining({ pass: true }));
});
});
it('fails if the promise is rejected', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
actual = Promise.reject('AsyncExpectationSpec error');
return matcher.compare(actual, '').then(function(result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: false,
- message: "Expected a promise to be resolved to '' but it was rejected.",
- }));
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: false,
+ message:
+ "Expected a promise to be resolved to '' but it was rejected."
+ })
+ );
});
});
it('fails if the promise is resolved to a different value', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
- actual = Promise.resolve({foo: 17});
+ actual = Promise.resolve({ foo: 17 });
- return matcher.compare(actual, {foo: 42}).then(function(result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: false,
- message: 'Expected a promise to be resolved to Object({ foo: 42 }) but it was resolved to Object({ foo: 17 }).',
- }));
+ return matcher.compare(actual, { foo: 42 }).then(function(result) {
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: false,
+ message:
+ 'Expected a promise to be resolved to Object({ foo: 42 }) but it was resolved to Object({ foo: 17 }).'
+ })
+ );
});
});
it('builds its message correctly when negated', function() {
jasmine.getEnv().requirePromises();
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
actual = Promise.resolve(true);
return matcher.compare(actual, true).then(function(result) {
- expect(result).toEqual(jasmine.objectContaining({
- pass: true,
- message: 'Expected a promise not to be resolved to true.'
- }));
+ expect(result).toEqual(
+ jasmine.objectContaining({
+ pass: true,
+ message: 'Expected a promise not to be resolved to true.'
+ })
+ );
});
});
it('supports custom equality testers', function() {
jasmine.getEnv().requirePromises();
- var customEqualityTesters = [function() { return true; }],
+ var customEqualityTesters = [
+ function() {
+ return true;
+ }
+ ],
matchersUtil = new jasmineUnderTest.MatchersUtil({
customTesters: customEqualityTesters,
pp: jasmineUnderTest.makePrettyPrinter()
@@ -69,12 +87,14 @@
actual = Promise.resolve('actual');
return matcher.compare(actual, 'expected').then(function(result) {
- expect(result).toEqual(jasmine.objectContaining({pass: true}));
+ expect(result).toEqual(jasmine.objectContaining({ pass: true }));
});
});
it('fails if actual is not a promise', function() {
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(matchersUtil),
actual = 'not a promise';
diff --git a/spec/core/matchers/matchersUtilSpec.js b/spec/core/matchers/matchersUtilSpec.js
index e3ee9e8..2014c8c 100644
--- a/spec/core/matchers/matchersUtilSpec.js
+++ b/spec/core/matchers/matchersUtilSpec.js
@@ -1,12 +1,12 @@
-describe("matchersUtil", function() {
- it("exposes the injected pretty-printer as .pp", function() {
+describe('matchersUtil', function() {
+ it('exposes the injected pretty-printer as .pp', function() {
var pp = function() {},
- matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp});
+ matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp });
expect(matchersUtil.pp).toBe(pp);
});
- describe("equals", function() {
+ describe('equals', function() {
describe('Properties', function() {
var fc;
@@ -78,79 +78,85 @@
});
});
- it("passes for literals that are triple-equal", function() {
+ it('passes for literals that are triple-equal', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(null, null)).toBe(true);
expect(matchersUtil.equals(void 0, void 0)).toBe(true);
});
- it("fails for things that are not equivalent", function() {
+ it('fails for things that are not equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.equals({a: "foo"}, 1)).toBe(false);
+ expect(matchersUtil.equals({ a: 'foo' }, 1)).toBe(false);
});
- it("passes for Strings that are equivalent", function() {
+ it('passes for Strings that are equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.equals("foo", "foo")).toBe(true);
+ expect(matchersUtil.equals('foo', 'foo')).toBe(true);
});
- it("fails for Strings that are not equivalent", function() {
+ it('fails for Strings that are not equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.equals("foo", "bar")).toBe(false);
+ expect(matchersUtil.equals('foo', 'bar')).toBe(false);
});
- it("passes for Numbers that are equivalent", function() {
+ it('passes for Numbers that are equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(123, 123)).toBe(true);
});
- it("fails for Numbers that are not equivalent", function() {
+ it('fails for Numbers that are not equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(123, 456)).toBe(false);
});
- it("fails for a Number and a String that have equivalent values", function() {
+ it('fails for a Number and a String that have equivalent values', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.equals(123, "123")).toBe(false);
+ expect(matchersUtil.equals(123, '123')).toBe(false);
});
- it("passes for Dates that are equivalent", function() {
+ it('passes for Dates that are equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.equals(new Date("Jan 1, 1970"), new Date("Jan 1, 1970"))).toBe(true);
+ expect(
+ matchersUtil.equals(new Date('Jan 1, 1970'), new Date('Jan 1, 1970'))
+ ).toBe(true);
});
- it("fails for Dates that are not equivalent", function() {
+ it('fails for Dates that are not equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.equals(new Date("Jan 1, 1970"), new Date("Feb 3, 1991"))).toBe(false);
+ expect(
+ matchersUtil.equals(new Date('Jan 1, 1970'), new Date('Feb 3, 1991'))
+ ).toBe(false);
});
- it("passes for Booleans that are equivalent", function() {
+ it('passes for Booleans that are equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(true, true)).toBe(true);
});
- it("fails for Booleans that are not equivalent", function() {
+ it('fails for Booleans that are not equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(true, false)).toBe(false);
});
- it("passes for RegExps that are equivalent", function() {
+ it('passes for RegExps that are equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(/foo/, /foo/)).toBe(true);
});
- it("fails for RegExps that are not equivalent", function() {
+ it('fails for RegExps that are not equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(/foo/, /bar/)).toBe(false);
- expect(matchersUtil.equals(new RegExp("foo", "i"), new RegExp("foo"))).toBe(false);
+ expect(
+ matchersUtil.equals(new RegExp('foo', 'i'), new RegExp('foo'))
+ ).toBe(false);
});
- it("passes for Arrays that are equivalent", function() {
+ it('passes for Arrays that are equivalent', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals([1, 2], [1, 2])).toBe(true);
});
- it("passes for Arrays that are equivalent, with elements added by changing length", function() {
+ it('passes for Arrays that are equivalent, with elements added by changing length', function() {
var foo = [],
matchersUtil = new jasmineUnderTest.MatchersUtil();
foo.length = 1;
@@ -158,19 +164,19 @@
expect(matchersUtil.equals(foo, [undefined])).toBe(true);
});
- it("fails for Arrays that have different lengths", function() {
+ it('fails for Arrays that have different lengths', function() {
matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals([1, 2], [1, 2, 3])).toBe(false);
});
- it("fails for Arrays that have different elements", function() {
+ it('fails for Arrays that have different elements', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals([1, 2, 3], [1, 5, 3])).toBe(false);
});
- it("fails for Arrays whose contents are equivalent, but have differing properties", function() {
- var one = [1,2,3],
- two = [1,2,3],
+ it('fails for Arrays whose contents are equivalent, but have differing properties', function() {
+ var one = [1, 2, 3],
+ two = [1, 2, 3],
matchersUtil = new jasmineUnderTest.MatchersUtil();
one.foo = 'bar';
@@ -179,9 +185,9 @@
expect(matchersUtil.equals(one, two)).toBe(false);
});
- it("passes for Arrays with equivalent contents and properties", function() {
- var one = [1,2,3],
- two = [1,2,3],
+ it('passes for Arrays with equivalent contents and properties', function() {
+ var one = [1, 2, 3],
+ two = [1, 2, 3],
matchersUtil = new jasmineUnderTest.MatchersUtil();
one.foo = 'bar';
@@ -190,17 +196,21 @@
expect(matchersUtil.equals(one, two)).toBe(true);
});
- it("passes for Errors that are the same type and have the same message", function() {
+ it('passes for Errors that are the same type and have the same message', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.equals(new Error("foo"), new Error("foo"))).toBe(true);
+ expect(matchersUtil.equals(new Error('foo'), new Error('foo'))).toBe(
+ true
+ );
});
- it("fails for Errors that are the same type and have different messages", function() {
+ it('fails for Errors that are the same type and have different messages', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.equals(new Error("foo"), new Error("bar"))).toBe(false);
+ expect(matchersUtil.equals(new Error('foo'), new Error('bar'))).toBe(
+ false
+ );
});
- it("fails for objects with different constructors", function() {
+ it('fails for objects with different constructors', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
function One() {}
function Two() {}
@@ -208,29 +218,39 @@
expect(matchersUtil.equals(new One(), new Two())).toBe(false);
});
- it("passes for Objects that are equivalent (simple case)", function() {
+ it('passes for Objects that are equivalent (simple case)', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.equals({a: "foo"}, {a: "foo"})).toBe(true);
+ expect(matchersUtil.equals({ a: 'foo' }, { a: 'foo' })).toBe(true);
});
- it("fails for Objects that are not equivalent (simple case)", function() {
+ it('fails for Objects that are not equivalent (simple case)', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.equals({a: "foo"}, {a: "bar"})).toBe(false);
+ expect(matchersUtil.equals({ a: 'foo' }, { a: 'bar' })).toBe(false);
});
- it("passes for Objects that are equivalent (deep case)", function() {
+ it('passes for Objects that are equivalent (deep case)', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.equals({a: "foo", b: { c: "bar"}}, {a: "foo", b: { c: "bar"}})).toBe(true);
+ expect(
+ matchersUtil.equals(
+ { a: 'foo', b: { c: 'bar' } },
+ { a: 'foo', b: { c: 'bar' } }
+ )
+ ).toBe(true);
});
- it("fails for Objects that are not equivalent (deep case)", function() {
+ it('fails for Objects that are not equivalent (deep case)', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.equals({a: "foo", b: { c: "baz"}}, {a: "foo", b: { c: "bar"}})).toBe(false);
+ expect(
+ matchersUtil.equals(
+ { a: 'foo', b: { c: 'baz' } },
+ { a: 'foo', b: { c: 'bar' } }
+ )
+ ).toBe(false);
});
- it("passes for Objects that are equivalent (with cycles)", function() {
- var actual = { a: "foo" },
- expected = { a: "foo" },
+ it('passes for Objects that are equivalent (with cycles)', function() {
+ var actual = { a: 'foo' },
+ expected = { a: 'foo' },
matchersUtil = new jasmineUnderTest.MatchersUtil();
actual.b = actual;
@@ -239,9 +259,9 @@
expect(matchersUtil.equals(actual, expected)).toBe(true);
});
- it("fails for Objects that are not equivalent (with cycles)", function() {
- var actual = { a: "foo" },
- expected = { a: "bar" },
+ it('fails for Objects that are not equivalent (with cycles)', function() {
+ var actual = { a: 'foo' },
+ expected = { a: 'bar' },
matchersUtil = new jasmineUnderTest.MatchersUtil();
actual.b = actual;
@@ -250,7 +270,7 @@
expect(matchersUtil.equals(actual, expected)).toBe(false);
});
- it("fails for Objects that have the same number of keys, but different keys/values", function () {
+ it('fails for Objects that have the same number of keys, but different keys/values', function() {
var expected = { a: undefined },
actual = { b: 1 },
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -258,61 +278,62 @@
expect(matchersUtil.equals(actual, expected)).toBe(false);
});
- it("fails when comparing an empty object to an empty array (issue #114)", function() {
+ it('fails when comparing an empty object to an empty array (issue #114)', function() {
var emptyObject = {},
emptyArray = [],
matchersUtil = new jasmineUnderTest.MatchersUtil();
-
expect(matchersUtil.equals(emptyObject, emptyArray)).toBe(false);
expect(matchersUtil.equals(emptyArray, emptyObject)).toBe(false);
});
- it("passes for equivalent frozen objects (GitHub issue #266)", function() {
+ it('passes for equivalent frozen objects (GitHub issue #266)', function() {
var a = { foo: 1 },
- b = {foo: 1 },
+ b = { foo: 1 },
matchersUtil = new jasmineUnderTest.MatchersUtil();
Object.freeze(a);
Object.freeze(b);
- expect(matchersUtil.equals(a,b)).toBe(true);
+ expect(matchersUtil.equals(a, b)).toBe(true);
});
- it("passes for equivalent Promises (GitHub issue #1314)", function() {
- if (typeof Promise === 'undefined') { return; }
+ it('passes for equivalent Promises (GitHub issue #1314)', function() {
+ if (typeof Promise === 'undefined') {
+ return;
+ }
- var p1 = new Promise(function () {}), // eslint-disable-line compat/compat
- p2 = new Promise(function () {}), // eslint-disable-line compat/compat
+ var p1 = new Promise(function() {}), // eslint-disable-line compat/compat
+ p2 = new Promise(function() {}), // eslint-disable-line compat/compat
matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(p1, p1)).toBe(true);
expect(matchersUtil.equals(p1, p2)).toBe(false);
});
- describe("when running in a browser", function() {
+ describe('when running in a browser', function() {
function isNotRunningInBrowser() {
- return typeof document === 'undefined'
+ return typeof document === 'undefined';
}
- it("passes for equivalent DOM nodes", function() {
+ it('passes for equivalent DOM nodes', function() {
if (isNotRunningInBrowser()) {
return;
}
- var a = document.createElement("div");
+ var a = document.createElement('div');
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- a.setAttribute("test-attr", "attr-value");
+ a.setAttribute('test-attr', 'attr-value');
a.appendChild(document.createTextNode('test'));
- var b = document.createElement("div");
- b.setAttribute("test-attr", "attr-value");
+ var b = document.createElement('div');
+ b.setAttribute('test-attr', 'attr-value');
b.appendChild(document.createTextNode('test'));
- expect(matchersUtil.equals(a,b)).toBe(true);
+ expect(matchersUtil.equals(a, b)).toBe(true);
});
- it("passes for equivalent objects from different frames", function() {
+ it('passes for equivalent objects from different frames', function() {
if (isNotRunningInBrowser()) {
return;
}
@@ -320,42 +341,44 @@
var iframe = document.createElement('iframe');
document.body.appendChild(iframe);
iframe.contentWindow.eval('window.testObject = {}');
- expect(matchersUtil.equals({}, iframe.contentWindow.testObject)).toBe(true);
+ expect(matchersUtil.equals({}, iframe.contentWindow.testObject)).toBe(
+ true
+ );
document.body.removeChild(iframe);
});
- it("fails for DOM nodes with different attributes or child nodes", function() {
+ it('fails for DOM nodes with different attributes or child nodes', function() {
if (isNotRunningInBrowser()) {
return;
}
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- var a = document.createElement("div");
- a.setAttribute("test-attr", "attr-value");
+ var a = document.createElement('div');
+ a.setAttribute('test-attr', 'attr-value');
a.appendChild(document.createTextNode('test'));
- var b = document.createElement("div");
- b.setAttribute("test-attr", "attr-value2");
+ var b = document.createElement('div');
+ b.setAttribute('test-attr', 'attr-value2');
b.appendChild(document.createTextNode('test'));
- expect(matchersUtil.equals(a,b)).toBe(false);
+ expect(matchersUtil.equals(a, b)).toBe(false);
- b.setAttribute("test-attr", "attr-value");
- expect(matchersUtil.equals(a,b)).toBe(true);
+ b.setAttribute('test-attr', 'attr-value');
+ expect(matchersUtil.equals(a, b)).toBe(true);
b.appendChild(document.createTextNode('2'));
- expect(matchersUtil.equals(a,b)).toBe(false);
+ expect(matchersUtil.equals(a, b)).toBe(false);
a.appendChild(document.createTextNode('2'));
- expect(matchersUtil.equals(a,b)).toBe(true);
+ expect(matchersUtil.equals(a, b)).toBe(true);
});
});
- describe("when running in Node", function() {
+ describe('when running in Node', function() {
function isNotRunningInNode() {
- return typeof require !== 'function'
+ return typeof require !== 'function';
}
- it("passes for equivalent objects from different vm contexts", function() {
+ it('passes for equivalent objects from different vm contexts', function() {
if (isNotRunningInNode()) {
return;
}
@@ -366,10 +389,10 @@
};
vm.runInNewContext('obj = {a: 1, b: 2}', sandbox);
- expect(matchersUtil.equals(sandbox.obj, {a: 1, b: 2})).toBe(true);
+ expect(matchersUtil.equals(sandbox.obj, { a: 1, b: 2 })).toBe(true);
});
- it("passes for equivalent arrays from different vm contexts", function() {
+ it('passes for equivalent arrays from different vm contexts', function() {
if (isNotRunningInNode()) {
return;
}
@@ -384,7 +407,7 @@
});
});
- it("passes when Any is used", function() {
+ it('passes when Any is used', function() {
var number = 3,
anyNumber = new jasmineUnderTest.Any(Number),
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -393,7 +416,7 @@
expect(matchersUtil.equals(anyNumber, number)).toBe(true);
});
- it("fails when Any is compared to something unexpected", function() {
+ it('fails when Any is compared to something unexpected', function() {
var number = 3,
anyString = new jasmineUnderTest.Any(String),
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -402,19 +425,19 @@
expect(matchersUtil.equals(anyString, number)).toBe(false);
});
- it("passes when ObjectContaining is used", function() {
+ it('passes when ObjectContaining is used', function() {
var obj = {
- foo: 3,
- bar: 7
- },
- containing = new jasmineUnderTest.ObjectContaining({foo: 3}),
+ foo: 3,
+ bar: 7
+ },
+ containing = new jasmineUnderTest.ObjectContaining({ foo: 3 }),
matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(obj, containing)).toBe(true);
expect(matchersUtil.equals(containing, obj)).toBe(true);
});
- it("passes when MapContaining is used", function() {
+ it('passes when MapContaining is used', function() {
jasmine.getEnv().requireFunctioningMaps();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -428,7 +451,7 @@
expect(matchersUtil.equals(containing, obj)).toBe(true);
});
- it("passes when SetContaining is used", function() {
+ it('passes when SetContaining is used', function() {
jasmine.getEnv().requireFunctioningSets();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -442,107 +465,159 @@
expect(matchersUtil.equals(containing, obj)).toBe(true);
});
- it("passes when an asymmetric equality tester returns true", function() {
- var tester = { asymmetricMatch: function(other) { return true; } },
+ it('passes when an asymmetric equality tester returns true', function() {
+ var tester = {
+ asymmetricMatch: function(other) {
+ return true;
+ }
+ },
matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(false, tester)).toBe(true);
expect(matchersUtil.equals(tester, false)).toBe(true);
});
- it("fails when an asymmetric equality tester returns false", function() {
- var tester = { asymmetricMatch: function(other) { return false; } },
+ it('fails when an asymmetric equality tester returns false', function() {
+ var tester = {
+ asymmetricMatch: function(other) {
+ return false;
+ }
+ },
matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(true, tester)).toBe(false);
expect(matchersUtil.equals(tester, true)).toBe(false);
});
- it("passes when ArrayContaining is used", function() {
- var arr = ["foo", "bar"],
+ it('passes when ArrayContaining is used', function() {
+ var arr = ['foo', 'bar'],
matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.equals(arr, new jasmineUnderTest.ArrayContaining(["bar"]))).toBe(true);
+ expect(
+ matchersUtil.equals(arr, new jasmineUnderTest.ArrayContaining(['bar']))
+ ).toBe(true);
});
- it("passes when a custom equality matcher passed to equals returns true", function() {
+ it('passes when a custom equality matcher passed to equals returns true', function() {
// TODO: remove this in the next major release.
- var tester = function(a, b) { return true; },
+ var tester = function(a, b) {
+ return true;
+ },
matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(1, 2, [tester])).toBe(true);
});
- it("passes when a custom equality matcher passed to the constructor returns true", function() {
- var tester = function(a, b) { return true; },
- matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [tester], pp: function() {}});
+ it('passes when a custom equality matcher passed to the constructor returns true', function() {
+ var tester = function(a, b) {
+ return true;
+ },
+ matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: [tester],
+ pp: function() {}
+ });
expect(matchersUtil.equals(1, 2)).toBe(true);
});
- it("passes for two empty Objects", function () {
+ it('passes for two empty Objects', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals({}, {})).toBe(true);
});
- describe("when a custom equality matcher is passed to equals that returns 'undefined'", function () {
+ describe("when a custom equality matcher is passed to equals that returns 'undefined'", function() {
// TODO: remove this in the next major release.
- var tester = function(a, b) { return jasmine.undefined; };
+ var tester = function(a, b) {
+ return jasmine.undefined;
+ };
- it("passes for two empty Objects", function () {
+ it('passes for two empty Objects', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals({}, {}, [tester])).toBe(true);
});
});
- describe("when a custom equality matcher is passed to the constructor that returns 'undefined'", function () {
- var tester = function(a, b) { return jasmine.undefined; };
+ describe("when a custom equality matcher is passed to the constructor that returns 'undefined'", function() {
+ var tester = function(a, b) {
+ return jasmine.undefined;
+ };
- it("passes for two empty Objects", function () {
- var matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [tester], pp: function() {}});
+ it('passes for two empty Objects', function() {
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: [tester],
+ pp: function() {}
+ });
expect(matchersUtil.equals({}, {})).toBe(true);
});
});
- it("fails for equivalents when a custom equality matcher passed to equals returns false", function() {
+ it('fails for equivalents when a custom equality matcher passed to equals returns false', function() {
// TODO: remove this in the next major release.
- var tester = function(a, b) { return false; },
+ var tester = function(a, b) {
+ return false;
+ },
matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(1, 1, [tester])).toBe(false);
});
- it("fails for equivalents when a custom equality matcher passed to the constructor returns false", function() {
- var tester = function(a, b) { return false; },
- matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [tester], pp: function() {}});
+ it('fails for equivalents when a custom equality matcher passed to the constructor returns false', function() {
+ var tester = function(a, b) {
+ return false;
+ },
+ matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: [tester],
+ pp: function() {}
+ });
expect(matchersUtil.equals(1, 1)).toBe(false);
});
- it("passes for an asymmetric equality tester that returns true when a custom equality tester passed to equals return false", function() {
+ it('passes for an asymmetric equality tester that returns true when a custom equality tester passed to equals return false', function() {
// TODO: remove this in the next major release.
- var asymmetricTester = { asymmetricMatch: function(other) { return true; } },
- symmetricTester = function(a, b) { return false; },
+ var asymmetricTester = {
+ asymmetricMatch: function(other) {
+ return true;
+ }
+ },
+ symmetricTester = function(a, b) {
+ return false;
+ },
matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.equals(asymmetricTester, true, [symmetricTester])).toBe(true);
- expect(matchersUtil.equals(true, asymmetricTester, [symmetricTester])).toBe(true);
+ expect(
+ matchersUtil.equals(asymmetricTester, true, [symmetricTester])
+ ).toBe(true);
+ expect(
+ matchersUtil.equals(true, asymmetricTester, [symmetricTester])
+ ).toBe(true);
});
- it("passes for an asymmetric equality tester that returns true when a custom equality tester passed to the constructor return false", function() {
- var asymmetricTester = { asymmetricMatch: function(other) { return true; } },
- symmetricTester = function(a, b) { return false; },
- matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [symmetricTester()], pp: function() {}});
+ it('passes for an asymmetric equality tester that returns true when a custom equality tester passed to the constructor return false', function() {
+ var asymmetricTester = {
+ asymmetricMatch: function(other) {
+ return true;
+ }
+ },
+ symmetricTester = function(a, b) {
+ return false;
+ },
+ matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: [symmetricTester()],
+ pp: function() {}
+ });
expect(matchersUtil.equals(asymmetricTester, true)).toBe(true);
expect(matchersUtil.equals(true, asymmetricTester)).toBe(true);
});
- describe("The compatibility shim passed to asymmetric equality testers", function() {
- describe("When equals is called with custom equality testers", function() {
- it("is both a matchersUtil and the custom equality testers passed to equals", function() {
- var asymmetricTester = jasmine.createSpyObj('tester', ['asymmetricMatch']),
- symmetricTester = function() { } ,
+ describe('The compatibility shim passed to asymmetric equality testers', function() {
+ describe('When equals is called with custom equality testers', function() {
+ it('is both a matchersUtil and the custom equality testers passed to equals', function() {
+ var asymmetricTester = jasmine.createSpyObj('tester', [
+ 'asymmetricMatch'
+ ]),
+ symmetricTester = function() {},
matchersUtil = new jasmineUnderTest.MatchersUtil(),
shim;
@@ -554,11 +629,16 @@
});
});
- describe("When equals is called with custom equality testers", function() {
- it("is both a matchersUtil and the custom equality testers passed to the constructor", function() {
- var asymmetricTester = jasmine.createSpyObj('tester', ['asymmetricMatch']),
- symmetricTester = function() { } ,
- matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [symmetricTester], pp: function() {}}),
+ describe('When equals is called with custom equality testers', function() {
+ it('is both a matchersUtil and the custom equality testers passed to the constructor', function() {
+ var asymmetricTester = jasmine.createSpyObj('tester', [
+ 'asymmetricMatch'
+ ]),
+ symmetricTester = function() {},
+ matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: [symmetricTester],
+ pp: function() {}
+ }),
shim;
matchersUtil.equals(true, asymmetricTester);
@@ -570,7 +650,7 @@
});
});
- it("passes when an Any is compared to an Any that checks for the same type", function() {
+ it('passes when an Any is compared to an Any that checks for the same type', function() {
var any1 = new jasmineUnderTest.Any(Function),
any2 = new jasmineUnderTest.Any(Function),
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -578,7 +658,7 @@
expect(matchersUtil.equals(any1, any2)).toBe(true);
});
- it("passes for null prototype objects with same properties", function () {
+ it('passes for null prototype objects with same properties', function() {
var objA = Object.create(null),
objB = Object.create(null),
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -589,7 +669,7 @@
expect(matchersUtil.equals(objA, objB)).toBe(true);
});
- it("fails for null prototype objects with different properties", function () {
+ it('fails for null prototype objects with different properties', function() {
var objA = Object.create(null),
objB = Object.create(null),
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -600,13 +680,13 @@
expect(matchersUtil.equals(objA, objB)).toBe(false);
});
- it("passes when comparing two empty sets", function() {
+ it('passes when comparing two empty sets', function() {
jasmine.getEnv().requireFunctioningSets();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(new Set(), new Set())).toBe(true); // eslint-disable-line compat/compat
});
- it("passes when comparing identical sets", function() {
+ it('passes when comparing identical sets', function() {
jasmine.getEnv().requireFunctioningSets();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -620,7 +700,7 @@
expect(matchersUtil.equals(setA, setB)).toBe(true);
});
- it("passes when comparing identical sets with different insertion order and simple elements", function() {
+ it('passes when comparing identical sets with different insertion order and simple elements', function() {
jasmine.getEnv().requireFunctioningSets();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -634,26 +714,26 @@
expect(matchersUtil.equals(setA, setB)).toBe(true);
});
- it("passes when comparing identical sets with different insertion order and complex elements 1", function() {
+ it('passes when comparing identical sets with different insertion order and complex elements 1', function() {
jasmine.getEnv().requireFunctioningSets();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var setA1 = new Set(); // eslint-disable-line compat/compat
- setA1.add(['a',3]);
- setA1.add([6,1]);
+ setA1.add(['a', 3]);
+ setA1.add([6, 1]);
var setA2 = new Set(); // eslint-disable-line compat/compat
- setA1.add(['y',3]);
- setA1.add([6,1]);
+ setA1.add(['y', 3]);
+ setA1.add([6, 1]);
var setA = new Set(); // eslint-disable-line compat/compat
setA.add(setA1);
setA.add(setA2);
var setB1 = new Set(); // eslint-disable-line compat/compat
- setB1.add([6,1]);
- setB1.add(['a',3]);
+ setB1.add([6, 1]);
+ setB1.add(['a', 3]);
var setB2 = new Set(); // eslint-disable-line compat/compat
- setB1.add([6,1]);
- setB1.add(['y',3]);
+ setB1.add([6, 1]);
+ setB1.add(['y', 3]);
var setB = new Set(); // eslint-disable-line compat/compat
setB.add(setB1);
setB.add(setB2);
@@ -661,21 +741,21 @@
expect(matchersUtil.equals(setA, setB)).toBe(true);
});
- it("passes when comparing identical sets with different insertion order and complex elements 2", function() {
+ it('passes when comparing identical sets with different insertion order and complex elements 2', function() {
jasmine.getEnv().requireFunctioningSets();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var setA = new Set(); // eslint-disable-line compat/compat
- setA.add([[1,2], [3,4]]);
- setA.add([[5,6], [7,8]]);
+ setA.add([[1, 2], [3, 4]]);
+ setA.add([[5, 6], [7, 8]]);
var setB = new Set(); // eslint-disable-line compat/compat
- setB.add([[5,6], [7,8]]);
- setB.add([[1,2], [3,4]]);
+ setB.add([[5, 6], [7, 8]]);
+ setB.add([[1, 2], [3, 4]]);
expect(matchersUtil.equals(setA, setB)).toBe(true);
});
- it("fails for sets with different elements", function() {
+ it('fails for sets with different elements', function() {
jasmine.getEnv().requireFunctioningSets();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var setA = new Set(); // eslint-disable-line compat/compat
@@ -690,7 +770,7 @@
expect(matchersUtil.equals(setA, setB)).toBe(false);
});
- it("fails for sets of different size", function() {
+ it('fails for sets of different size', function() {
jasmine.getEnv().requireFunctioningSets();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var setA = new Set(); // eslint-disable-line compat/compat
@@ -704,13 +784,13 @@
expect(matchersUtil.equals(setA, setB)).toBe(false);
});
- it("passes when comparing two empty maps", function() {
+ it('passes when comparing two empty maps', function() {
jasmine.getEnv().requireFunctioningMaps();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.equals(new Map(), new Map())).toBe(true); // eslint-disable-line compat/compat
});
- it("passes when comparing identical maps", function() {
+ it('passes when comparing identical maps', function() {
jasmine.getEnv().requireFunctioningMaps();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var mapA = new Map(); // eslint-disable-line compat/compat
@@ -720,19 +800,19 @@
expect(matchersUtil.equals(mapA, mapB)).toBe(true);
});
- it("passes when comparing identical maps with different insertion order", function() {
+ it('passes when comparing identical maps with different insertion order', function() {
jasmine.getEnv().requireFunctioningMaps();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var mapA = new Map(); // eslint-disable-line compat/compat
- mapA.set("a", 3);
+ mapA.set('a', 3);
mapA.set(6, 1);
var mapB = new Map(); // eslint-disable-line compat/compat
mapB.set(6, 1);
- mapB.set("a", 3);
+ mapB.set('a', 3);
expect(matchersUtil.equals(mapA, mapB)).toBe(true);
});
- it("fails for maps with different elements", function() {
+ it('fails for maps with different elements', function() {
jasmine.getEnv().requireFunctioningMaps();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var mapA = new Map(); // eslint-disable-line compat/compat
@@ -745,7 +825,7 @@
expect(matchersUtil.equals(mapA, mapB)).toBe(false);
});
- it("fails for maps of different size", function() {
+ it('fails for maps of different size', function() {
jasmine.getEnv().requireFunctioningMaps();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var mapA = new Map(); // eslint-disable-line compat/compat
@@ -756,8 +836,11 @@
expect(matchersUtil.equals(mapA, mapB)).toBe(false);
});
- describe("when running in an environment with array polyfills", function() {
- var findIndexDescriptor = Object.getOwnPropertyDescriptor(Array.prototype, 'findIndex');
+ describe('when running in an environment with array polyfills', function() {
+ var findIndexDescriptor = Object.getOwnPropertyDescriptor(
+ Array.prototype,
+ 'findIndex'
+ );
if (!findIndexDescriptor) {
return;
}
@@ -765,9 +848,11 @@
beforeEach(function() {
Object.defineProperty(Array.prototype, 'findIndex', {
enumerable: true,
- value: function (predicate) {
+ value: function(predicate) {
if (this === null) {
- throw new TypeError('Array.prototype.findIndex called on null or undefined');
+ throw new TypeError(
+ 'Array.prototype.findIndex called on null or undefined'
+ );
}
if (typeof predicate !== 'function') {
@@ -792,7 +877,11 @@
});
afterEach(function() {
- Object.defineProperty(Array.prototype, 'findIndex', findIndexDescriptor);
+ Object.defineProperty(
+ Array.prototype,
+ 'findIndex',
+ findIndexDescriptor
+ );
});
it("passes when there's an array polyfill", function() {
@@ -800,10 +889,12 @@
});
});
- describe("Building diffs for asymmetric equality testers", function() {
- it("diffs the values returned by valuesForDiff_", function() {
+ describe('Building diffs for asymmetric equality testers', function() {
+ it('diffs the values returned by valuesForDiff_', function() {
var tester = {
- asymmetricMatch: function() { return false; },
+ asymmetricMatch: function() {
+ return false;
+ },
valuesForDiff_: function() {
return {
self: 'asymmetric tester value',
@@ -811,30 +902,50 @@
};
}
},
- actual = {x: 42},
- expected = {x: tester},
- diffBuilder = jasmine.createSpyObj('diffBuilder', ['recordMismatch', 'withPath', 'setRoots']);
+ actual = { x: 42 },
+ expected = { x: tester },
+ diffBuilder = jasmine.createSpyObj('diffBuilder', [
+ 'recordMismatch',
+ 'withPath',
+ 'setRoots'
+ ]);
- diffBuilder.withPath.and.callFake(function(p, block) { block(); });
+ diffBuilder.withPath.and.callFake(function(p, block) {
+ block();
+ });
jasmineUnderTest.matchersUtil.equals(actual, expected, [], diffBuilder);
expect(diffBuilder.setRoots).toHaveBeenCalledWith(actual, expected);
- expect(diffBuilder.withPath).toHaveBeenCalledWith('x', jasmine.any(Function));
+ expect(diffBuilder.withPath).toHaveBeenCalledWith(
+ 'x',
+ jasmine.any(Function)
+ );
expect(diffBuilder.recordMismatch).toHaveBeenCalledWith();
});
- it("records both objects when the tester does not implement valuesForDiff", function() {
+ it('records both objects when the tester does not implement valuesForDiff', function() {
var tester = {
- asymmetricMatch: function() { return false; },
+ asymmetricMatch: function() {
+ return false;
+ }
},
- actual = {x: 42},
- expected = {x: tester},
- diffBuilder = jasmine.createSpyObj('diffBuilder', ['recordMismatch', 'withPath', 'setRoots']);
- diffBuilder.withPath.and.callFake(function(p, block) { block(); });
+ actual = { x: 42 },
+ expected = { x: tester },
+ diffBuilder = jasmine.createSpyObj('diffBuilder', [
+ 'recordMismatch',
+ 'withPath',
+ 'setRoots'
+ ]);
+ diffBuilder.withPath.and.callFake(function(p, block) {
+ block();
+ });
jasmineUnderTest.matchersUtil.equals(actual, expected, [], diffBuilder);
expect(diffBuilder.setRoots).toHaveBeenCalledWith(actual, expected);
- expect(diffBuilder.withPath).toHaveBeenCalledWith('x', jasmine.any(Function));
+ expect(diffBuilder.withPath).toHaveBeenCalledWith(
+ 'x',
+ jasmine.any(Function)
+ );
expect(diffBuilder.recordMismatch).toHaveBeenCalledWith();
});
});
@@ -848,8 +959,14 @@
spyOn(diffBuilder, 'withPath').and.callThrough();
matchersUtil.equals([1], [2], [], diffBuilder);
- expect(diffBuilder.withPath).toHaveBeenCalledWith('length', jasmine.any(Function));
- expect(diffBuilder.withPath).toHaveBeenCalledWith(0, jasmine.any(Function));
+ expect(diffBuilder.withPath).toHaveBeenCalledWith(
+ 'length',
+ jasmine.any(Function)
+ );
+ expect(diffBuilder.withPath).toHaveBeenCalledWith(
+ 0,
+ jasmine.any(Function)
+ );
expect(diffBuilder.recordMismatch).toHaveBeenCalledWith();
});
@@ -861,69 +978,84 @@
spyOn(diffBuilder, 'withPath').and.callThrough();
matchersUtil.equals([1], [2], diffBuilder);
- expect(diffBuilder.withPath).toHaveBeenCalledWith('length', jasmine.any(Function));
- expect(diffBuilder.withPath).toHaveBeenCalledWith(0, jasmine.any(Function));
+ expect(diffBuilder.withPath).toHaveBeenCalledWith(
+ 'length',
+ jasmine.any(Function)
+ );
+ expect(diffBuilder.withPath).toHaveBeenCalledWith(
+ 0,
+ jasmine.any(Function)
+ );
expect(diffBuilder.recordMismatch).toHaveBeenCalled();
});
});
- describe("contains", function() {
- it("passes when expected is a substring of actual", function() {
+ describe('contains', function() {
+ it('passes when expected is a substring of actual', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.contains("ABC", "BC")).toBe(true);
+ expect(matchersUtil.contains('ABC', 'BC')).toBe(true);
});
- it("fails when expected is a not substring of actual", function() {
+ it('fails when expected is a not substring of actual', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.contains("ABC", "X")).toBe(false);
+ expect(matchersUtil.contains('ABC', 'X')).toBe(false);
});
- it("passes when expected is an element in an actual array", function() {
+ it('passes when expected is an element in an actual array', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.contains(['foo', 'bar'], 'foo')).toBe(true);
});
- it("fails when expected is not an element in an actual array", function() {
+ it('fails when expected is not an element in an actual array', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.contains(['foo', 'bar'], 'baz')).toBe(false);
});
- it("passes with mixed-element arrays", function() {
+ it('passes with mixed-element arrays', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.contains(["foo", {some: "bar"}], "foo")).toBe(true);
- expect(matchersUtil.contains(["foo", {some: "bar"}], {some: "bar"})).toBe(true);
+ expect(matchersUtil.contains(['foo', { some: 'bar' }], 'foo')).toBe(true);
+ expect(
+ matchersUtil.contains(['foo', { some: 'bar' }], { some: 'bar' })
+ ).toBe(true);
});
- it("uses custom equality testers if passed to contains and actual is an Array", function() {
+ it('uses custom equality testers if passed to contains and actual is an Array', function() {
// TODO: remove this in the next major release.
- var customTester = function(a, b) {return true;},
+ var customTester = function(a, b) {
+ return true;
+ },
matchersUtil = new jasmineUnderTest.MatchersUtil();
- expect(matchersUtil.contains([1, 2], 3, [customTester])).toBe(true);
+ expect(matchersUtil.contains([1, 2], 3, [customTester])).toBe(true);
});
- it("uses custom equality testers if passed to the constructor and actual is an Array", function() {
- var customTester = function(a, b) {return true;},
- matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [customTester], pp: function() {}});
+ it('uses custom equality testers if passed to the constructor and actual is an Array', function() {
+ var customTester = function(a, b) {
+ return true;
+ },
+ matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: [customTester],
+ pp: function() {}
+ });
expect(matchersUtil.contains([1, 2], 3)).toBe(true);
});
- it("fails when actual is undefined", function() {
+ it('fails when actual is undefined', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.contains(undefined, 'A')).toBe(false);
});
- it("fails when actual is null", function() {
+ it('fails when actual is null', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
expect(matchersUtil.contains(null, 'A')).toBe(false);
});
- it("passes with array-like objects", function() {
+ it('passes with array-like objects', function() {
var capturedArgs = null,
matchersUtil = new jasmineUnderTest.MatchersUtil();
- function testFunction(){
+ function testFunction() {
capturedArgs = arguments;
}
@@ -931,11 +1063,11 @@
expect(matchersUtil.contains(capturedArgs, 'bar')).toBe(true);
});
- it("passes for set members", function() {
+ it('passes for set members', function() {
jasmine.getEnv().requireFunctioningSets();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
- var setItem = {'foo': 'bar'};
+ var setItem = { foo: 'bar' };
var set = new Set(); // eslint-disable-line compat/compat
set.add(setItem);
@@ -943,61 +1075,78 @@
});
// documenting current behavior
- it("fails (!) for objects that equal to a set member", function() {
+ it('fails (!) for objects that equal to a set member', function() {
jasmine.getEnv().requireFunctioningSets();
var matchersUtil = new jasmineUnderTest.MatchersUtil();
var set = new Set(); // eslint-disable-line compat/compat
- set.add({'foo': 'bar'});
+ set.add({ foo: 'bar' });
- expect(matchersUtil.contains(set, {'foo': 'bar'})).toBe(false);
+ expect(matchersUtil.contains(set, { foo: 'bar' })).toBe(false);
});
});
- describe("buildFailureMessage", function() {
-
- it("builds an English sentence for a failure case", function() {
- var actual = "foo",
- name = "toBar",
+ describe('buildFailureMessage', function() {
+ it('builds an English sentence for a failure case', function() {
+ var actual = 'foo',
+ name = 'toBar',
pp = jasmineUnderTest.makePrettyPrinter(),
- matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
+ matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
message = matchersUtil.buildFailureMessage(name, false, actual);
expect(message).toEqual("Expected 'foo' to bar.");
});
it("builds an English sentence for a 'not' failure case", function() {
- var actual = "foo",
- name = "toBar",
+ var actual = 'foo',
+ name = 'toBar',
isNot = true,
pp = jasmineUnderTest.makePrettyPrinter(),
- matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
- message = message = matchersUtil.buildFailureMessage(name, isNot, actual);
+ matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
+ message = (message = matchersUtil.buildFailureMessage(
+ name,
+ isNot,
+ actual
+ ));
expect(message).toEqual("Expected 'foo' not to bar.");
});
- it("builds an English sentence for an arbitrary array of expected arguments", function() {
- var actual = "foo",
- name = "toBar",
+ it('builds an English sentence for an arbitrary array of expected arguments', function() {
+ var actual = 'foo',
+ name = 'toBar',
pp = jasmineUnderTest.makePrettyPrinter(),
- matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
- message = matchersUtil.buildFailureMessage(name, false, actual, "quux", "corge");
+ matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
+ message = matchersUtil.buildFailureMessage(
+ name,
+ false,
+ actual,
+ 'quux',
+ 'corge'
+ );
expect(message).toEqual("Expected 'foo' to bar 'quux', 'corge'.");
});
- it("uses the injected pretty-printer to format the expecteds and actual", function() {
- var actual = "foo",
- expected1 = "qux",
- expected2 = "grault",
- name = "toBar",
+ it('uses the injected pretty-printer to format the expecteds and actual', function() {
+ var actual = 'foo',
+ expected1 = 'qux',
+ expected2 = 'grault',
+ name = 'toBar',
isNot = false,
- pp = function(value) { return '<' + value + '>'; },
- matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
- message = message = matchersUtil.buildFailureMessage(name, isNot, actual, expected1, expected2);
+ pp = function(value) {
+ return '<' + value + '>';
+ },
+ matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
+ message = (message = matchersUtil.buildFailureMessage(
+ name,
+ isNot,
+ actual,
+ expected1,
+ expected2
+ ));
- expect(message).toEqual("Expected <foo> to bar <qux>, <grault>.");
+ expect(message).toEqual('Expected <foo> to bar <qux>, <grault>.');
});
});
});
diff --git a/spec/core/matchers/toBeCloseToSpec.js b/spec/core/matchers/toBeCloseToSpec.js
index 402ce88..2594e9e 100644
--- a/spec/core/matchers/toBeCloseToSpec.js
+++ b/spec/core/matchers/toBeCloseToSpec.js
@@ -1,5 +1,5 @@
-describe("toBeCloseTo", function() {
- it("passes when within two decimal places by default", function() {
+describe('toBeCloseTo', function() {
+ it('passes when within two decimal places by default', function() {
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
result;
@@ -13,7 +13,7 @@
expect(result.pass).toBe(true);
});
- it("fails when not within two decimal places by default", function() {
+ it('fails when not within two decimal places by default', function() {
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
result;
@@ -24,7 +24,7 @@
expect(result.pass).toBe(false);
});
- it("accepts an optional precision argument", function() {
+ it('accepts an optional precision argument', function() {
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
result;
@@ -47,23 +47,29 @@
expect(result.pass).toBe(true);
});
- it("fails when one of the arguments is null", function() {
+ it('fails when one of the arguments is null', function() {
var matcher = jasmineUnderTest.matchers.toBeCloseTo();
expect(function() {
matcher.compare(null, null);
- }).toThrowError('Cannot use toBeCloseTo with null. Arguments evaluated to: expect(null).toBeCloseTo(null).');
+ }).toThrowError(
+ 'Cannot use toBeCloseTo with null. Arguments evaluated to: expect(null).toBeCloseTo(null).'
+ );
expect(function() {
matcher.compare(0, null);
- }).toThrowError('Cannot use toBeCloseTo with null. Arguments evaluated to: expect(0).toBeCloseTo(null).');
+ }).toThrowError(
+ 'Cannot use toBeCloseTo with null. Arguments evaluated to: expect(0).toBeCloseTo(null).'
+ );
expect(function() {
matcher.compare(null, 0);
- }).toThrowError('Cannot use toBeCloseTo with null. Arguments evaluated to: expect(null).toBeCloseTo(0).');
+ }).toThrowError(
+ 'Cannot use toBeCloseTo with null. Arguments evaluated to: expect(null).toBeCloseTo(0).'
+ );
});
- it("rounds expected values", function() {
+ it('rounds expected values', function() {
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
result;
@@ -91,15 +97,15 @@
expect(result.pass).toBe(true);
});
- it("handles edge cases with rounding", function () {
+ it('handles edge cases with rounding', function() {
var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
result;
- // these cases resulted in false negatives in version of V8
+ // these cases resulted in false negatives in version of V8
// included in Node.js 12 and Chrome 74 (and Edge Chromium)
result = matcher.compare(4.030904708957288, 4.0309, 5);
expect(result.pass).toBe(true);
- result = matcher.compare(4.82665525779431,4.82666, 5);
+ result = matcher.compare(4.82665525779431, 4.82666, 5);
expect(result.pass).toBe(true);
result = matcher.compare(-2.82665525779431, -2.82666, 5);
expect(result.pass).toBe(true);
diff --git a/spec/core/matchers/toBeDefinedSpec.js b/spec/core/matchers/toBeDefinedSpec.js
index 5649f42..4b89c9a 100644
--- a/spec/core/matchers/toBeDefinedSpec.js
+++ b/spec/core/matchers/toBeDefinedSpec.js
@@ -1,18 +1,17 @@
-describe("toBeDefined", function() {
- it("matches for defined values", function() {
+describe('toBeDefined', function() {
+ it('matches for defined values', function() {
var matcher = jasmineUnderTest.matchers.toBeDefined(),
result;
-
result = matcher.compare('foo');
expect(result.pass).toBe(true);
});
- it("fails when matching undefined values", function() {
+ it('fails when matching undefined values', function() {
var matcher = jasmineUnderTest.matchers.toBeDefined(),
result;
result = matcher.compare(void 0);
expect(result.pass).toBe(false);
- })
+ });
});
diff --git a/spec/core/matchers/toBeFalseSpec.js b/spec/core/matchers/toBeFalseSpec.js
index 7c0900e..47e2b38 100644
--- a/spec/core/matchers/toBeFalseSpec.js
+++ b/spec/core/matchers/toBeFalseSpec.js
@@ -1,5 +1,5 @@
-describe("toBeFalse", function() {
- it("passes for false", function() {
+describe('toBeFalse', function() {
+ it('passes for false', function() {
var matcher = jasmineUnderTest.matchers.toBeFalse(),
result;
@@ -7,7 +7,7 @@
expect(result.pass).toBe(true);
});
- it("fails for non-false", function() {
+ it('fails for non-false', function() {
var matcher = jasmineUnderTest.matchers.toBeFalse(),
result;
@@ -15,7 +15,7 @@
expect(result.pass).toBe(false);
});
- it("fails for falsy", function() {
+ it('fails for falsy', function() {
var matcher = jasmineUnderTest.matchers.toBeFalse(),
result;
diff --git a/spec/core/matchers/toBeFalsySpec.js b/spec/core/matchers/toBeFalsySpec.js
index 2099234..ec4a98e 100644
--- a/spec/core/matchers/toBeFalsySpec.js
+++ b/spec/core/matchers/toBeFalsySpec.js
@@ -1,4 +1,4 @@
-describe("toBeFalsy", function() {
+describe('toBeFalsy', function() {
it("passes for 'falsy' values", function() {
var matcher = jasmineUnderTest.matchers.toBeFalsy(),
result;
@@ -29,7 +29,7 @@
result = matcher.compare(1);
expect(result.pass).toBe(false);
- result = matcher.compare("foo");
+ result = matcher.compare('foo');
expect(result.pass).toBe(false);
result = matcher.compare({});
diff --git a/spec/core/matchers/toBeGreaterThanOrEqualSpec.js b/spec/core/matchers/toBeGreaterThanOrEqualSpec.js
index 81817c1..444cd31 100644
--- a/spec/core/matchers/toBeGreaterThanOrEqualSpec.js
+++ b/spec/core/matchers/toBeGreaterThanOrEqualSpec.js
@@ -1,5 +1,5 @@
-describe("toBeGreaterThanOrEqual", function() {
- it("passes when actual >= expected", function() {
+describe('toBeGreaterThanOrEqual', function() {
+ it('passes when actual >= expected', function() {
var matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual(),
result;
@@ -16,7 +16,7 @@
expect(result.pass).toBe(true);
});
- it("fails when actual < expected", function() {
+ it('fails when actual < expected', function() {
var matcher = jasmineUnderTest.matchers.toBeGreaterThanOrEqual(),
result;
@@ -25,5 +25,5 @@
result = matcher.compare(1, 1.0000001);
expect(result.pass).toBe(false);
- })
+ });
});
diff --git a/spec/core/matchers/toBeGreaterThanSpec.js b/spec/core/matchers/toBeGreaterThanSpec.js
index 75b9282..f157e52 100644
--- a/spec/core/matchers/toBeGreaterThanSpec.js
+++ b/spec/core/matchers/toBeGreaterThanSpec.js
@@ -1,5 +1,5 @@
-describe("toBeGreaterThan", function() {
- it("passes when actual > expected", function() {
+describe('toBeGreaterThan', function() {
+ it('passes when actual > expected', function() {
var matcher = jasmineUnderTest.matchers.toBeGreaterThan(),
result;
@@ -7,7 +7,7 @@
expect(result.pass).toBe(true);
});
- it("fails when actual <= expected", function() {
+ it('fails when actual <= expected', function() {
var matcher = jasmineUnderTest.matchers.toBeGreaterThan(),
result;
diff --git a/spec/core/matchers/toBeInstanceOfSpec.js b/spec/core/matchers/toBeInstanceOfSpec.js
index d8355af..f63ec84 100644
--- a/spec/core/matchers/toBeInstanceOfSpec.js
+++ b/spec/core/matchers/toBeInstanceOfSpec.js
@@ -92,13 +92,14 @@
describe('when expecting Function', function() {
it('passes for a function', function() {
- var fn = function() { };
+ var fn = function() {};
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(fn, Function);
expect(result).toEqual({
pass: true,
- message: 'Expected instance of Function not to be an instance of Function'
+ message:
+ 'Expected instance of Function not to be an instance of Function'
});
});
@@ -111,13 +112,14 @@
var result = matcher.compare(fn, Function);
expect(result).toEqual({
pass: true,
- message: 'Expected instance of AsyncFunction not to be an instance of Function'
+ message:
+ 'Expected instance of AsyncFunction not to be an instance of Function'
});
});
});
describe('when expecting Object', function() {
- function Animal() { }
+ function Animal() {}
it('passes for any object', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
@@ -164,14 +166,15 @@
var result = matcher.compare(object, Object);
expect(result).toEqual({
pass: true,
- message: 'Expected instance of null({ }) not to be an instance of Object'
+ message:
+ 'Expected instance of null({ }) not to be an instance of Object'
});
});
});
describe('when expecting a user-defined class', function() {
// Base class
- function Animal() { }
+ function Animal() {}
// Subclasses, defined using syntax that is as old as possible
function Dog() {
@@ -218,8 +221,10 @@
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
expect(function() {
matcher.compare({}, 'Error');
- }).toThrowError('<toBeInstanceOf> : Expected value is not a constructor function\n' +
- 'Usage: expect(value).toBeInstanceOf(<ConstructorFunction>)');
+ }).toThrowError(
+ '<toBeInstanceOf> : Expected value is not a constructor function\n' +
+ 'Usage: expect(value).toBeInstanceOf(<ConstructorFunction>)'
+ );
});
it('raises an error if missing an expected value', function() {
@@ -228,7 +233,9 @@
});
expect(function() {
matcher.compare({}, undefined);
- }).toThrowError('<toBeInstanceOf> : Expected value is not a constructor function\n' +
- 'Usage: expect(value).toBeInstanceOf(<ConstructorFunction>)');
+ }).toThrowError(
+ '<toBeInstanceOf> : Expected value is not a constructor function\n' +
+ 'Usage: expect(value).toBeInstanceOf(<ConstructorFunction>)'
+ );
});
});
diff --git a/spec/core/matchers/toBeLessThanOrEqualSpec.js b/spec/core/matchers/toBeLessThanOrEqualSpec.js
index 20d36e8..0aa7940 100644
--- a/spec/core/matchers/toBeLessThanOrEqualSpec.js
+++ b/spec/core/matchers/toBeLessThanOrEqualSpec.js
@@ -1,5 +1,5 @@
-describe("toBeLessThanOrEqual", function() {
- it("passes when actual <= expected", function() {
+describe('toBeLessThanOrEqual', function() {
+ it('passes when actual <= expected', function() {
var matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual(),
result;
@@ -11,12 +11,12 @@
result = matcher.compare(1, 1.0000001);
expect(result.pass).toBe(true);
-
+
result = matcher.compare(1.0, 1.0);
expect(result.pass).toBe(true);
});
- it("fails when actual < expected", function() {
+ it('fails when actual < expected', function() {
var matcher = jasmineUnderTest.matchers.toBeLessThanOrEqual(),
result;
diff --git a/spec/core/matchers/toBeLessThanSpec.js b/spec/core/matchers/toBeLessThanSpec.js
index 55868ec..24a1d9a 100644
--- a/spec/core/matchers/toBeLessThanSpec.js
+++ b/spec/core/matchers/toBeLessThanSpec.js
@@ -1,5 +1,5 @@
-describe("toBeLessThan", function() {
- it("passes when actual < expected", function() {
+describe('toBeLessThan', function() {
+ it('passes when actual < expected', function() {
var matcher = jasmineUnderTest.matchers.toBeLessThan(),
result;
@@ -7,7 +7,7 @@
expect(result.pass).toBe(true);
});
- it("fails when actual <= expected", function() {
+ it('fails when actual <= expected', function() {
var matcher = jasmineUnderTest.matchers.toBeLessThan(),
result;
diff --git a/spec/core/matchers/toBeNaNSpec.js b/spec/core/matchers/toBeNaNSpec.js
index e859f64..d38ffed 100644
--- a/spec/core/matchers/toBeNaNSpec.js
+++ b/spec/core/matchers/toBeNaNSpec.js
@@ -1,14 +1,14 @@
-describe("toBeNaN", function() {
- it("passes for NaN with a custom .not fail", function() {
+describe('toBeNaN', function() {
+ it('passes for NaN with a custom .not fail', function() {
var matcher = jasmineUnderTest.matchers.toBeNaN(),
result;
result = matcher.compare(Number.NaN);
expect(result.pass).toBe(true);
- expect(result.message).toEqual("Expected actual not to be NaN.");
+ expect(result.message).toEqual('Expected actual not to be NaN.');
});
- it("fails for anything not a NaN", function() {
+ it('fails for anything not a NaN', function() {
var matcher = jasmineUnderTest.matchers.toBeNaN(),
result;
@@ -28,12 +28,12 @@
expect(result.pass).toBe(false);
});
- it("has a custom message on failure", function() {
+ it('has a custom message on failure', function() {
var matcher = jasmineUnderTest.matchers.toBeNaN({
pp: jasmineUnderTest.makePrettyPrinter()
}),
result = matcher.compare(0);
- expect(result.message()).toEqual("Expected 0 to be NaN.");
+ expect(result.message()).toEqual('Expected 0 to be NaN.');
});
});
diff --git a/spec/core/matchers/toBeNegativeInfinitySpec.js b/spec/core/matchers/toBeNegativeInfinitySpec.js
index 876bf20..d771378 100644
--- a/spec/core/matchers/toBeNegativeInfinitySpec.js
+++ b/spec/core/matchers/toBeNegativeInfinitySpec.js
@@ -1,4 +1,4 @@
-describe("toBeNegativeInfinity", function() {
+describe('toBeNegativeInfinity', function() {
it("fails for anything that isn't -Infinity", function() {
var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(),
result;
@@ -13,21 +13,20 @@
expect(result.pass).toBe(false);
});
- it("has a custom message on failure", function() {
+ it('has a custom message on failure', function() {
var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity({
pp: jasmineUnderTest.makePrettyPrinter()
}),
result = matcher.compare(0);
- expect(result.message()).toEqual("Expected 0 to be -Infinity.")
+ expect(result.message()).toEqual('Expected 0 to be -Infinity.');
});
- it("succeeds for -Infinity", function() {
+ it('succeeds for -Infinity', function() {
var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(),
result = matcher.compare(Number.NEGATIVE_INFINITY);
expect(result.pass).toBe(true);
- expect(result.message).toEqual("Expected actual not to be -Infinity.")
+ expect(result.message).toEqual('Expected actual not to be -Infinity.');
});
-
});
diff --git a/spec/core/matchers/toBeNullSpec.js b/spec/core/matchers/toBeNullSpec.js
index 35dfe8d..da5c285 100644
--- a/spec/core/matchers/toBeNullSpec.js
+++ b/spec/core/matchers/toBeNullSpec.js
@@ -1,5 +1,5 @@
-describe("toBeNull", function() {
- it("passes for null", function() {
+describe('toBeNull', function() {
+ it('passes for null', function() {
var matcher = jasmineUnderTest.matchers.toBeNull(),
result;
@@ -7,7 +7,7 @@
expect(result.pass).toBe(true);
});
- it("fails for non-null", function() {
+ it('fails for non-null', function() {
var matcher = jasmineUnderTest.matchers.toBeNull(),
result;
diff --git a/spec/core/matchers/toBePositiveInfinitySpec.js b/spec/core/matchers/toBePositiveInfinitySpec.js
index 6fc91b6..3673fb6 100644
--- a/spec/core/matchers/toBePositiveInfinitySpec.js
+++ b/spec/core/matchers/toBePositiveInfinitySpec.js
@@ -1,4 +1,4 @@
-describe("toBePositiveInfinity", function() {
+describe('toBePositiveInfinity', function() {
it("fails for anything that isn't Infinity", function() {
var matcher = jasmineUnderTest.matchers.toBePositiveInfinity(),
result;
@@ -13,21 +13,20 @@
expect(result.pass).toBe(false);
});
- it("has a custom message on failure", function() {
+ it('has a custom message on failure', function() {
var matcher = jasmineUnderTest.matchers.toBePositiveInfinity({
pp: jasmineUnderTest.makePrettyPrinter()
}),
result = matcher.compare(0);
- expect(result.message()).toEqual("Expected 0 to be Infinity.")
+ expect(result.message()).toEqual('Expected 0 to be Infinity.');
});
- it("succeeds for Infinity", function() {
+ it('succeeds for Infinity', function() {
var matcher = jasmineUnderTest.matchers.toBePositiveInfinity(),
result = matcher.compare(Number.POSITIVE_INFINITY);
expect(result.pass).toBe(true);
- expect(result.message).toEqual("Expected actual not to be Infinity.")
+ expect(result.message).toEqual('Expected actual not to be Infinity.');
});
-
});
diff --git a/spec/core/matchers/toBeSpec.js b/spec/core/matchers/toBeSpec.js
index 4d74a6d..b577b0d 100644
--- a/spec/core/matchers/toBeSpec.js
+++ b/spec/core/matchers/toBeSpec.js
@@ -1,5 +1,5 @@
-describe("toBe", function() {
- it("passes with no message when actual === expected", function() {
+describe('toBe', function() {
+ it('passes with no message when actual === expected', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result;
@@ -8,29 +8,37 @@
expect(result.pass).toBe(true);
});
- it("passes with a custom message when expected is an array", function() {
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
+ it('passes with a custom message when expected is an array', function() {
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result,
array = [1];
result = matcher.compare(array, array);
expect(result.pass).toBe(true);
- expect(result.message).toBe("Expected [ 1 ] not to be [ 1 ]. Tip: To check for deep equality, use .toEqual() instead of .toBe().")
+ expect(result.message).toBe(
+ 'Expected [ 1 ] not to be [ 1 ]. Tip: To check for deep equality, use .toEqual() instead of .toBe().'
+ );
});
- it("passes with a custom message when expected is an object", function() {
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
+ it('passes with a custom message when expected is an object', function() {
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result,
- obj = {foo: "bar"};
+ obj = { foo: 'bar' };
result = matcher.compare(obj, obj);
expect(result.pass).toBe(true);
- expect(result.message).toBe("Expected Object({ foo: 'bar' }) not to be Object({ foo: 'bar' }). Tip: To check for deep equality, use .toEqual() instead of .toBe().")
+ expect(result.message).toBe(
+ "Expected Object({ foo: 'bar' }) not to be Object({ foo: 'bar' }). Tip: To check for deep equality, use .toEqual() instead of .toBe()."
+ );
});
- it("fails with no message when actual !== expected", function() {
+ it('fails with no message when actual !== expected', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result;
@@ -40,35 +48,47 @@
expect(result.message).toBeUndefined();
});
- it("fails with a custom message when expected is an array", function() {
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
+ it('fails with a custom message when expected is an array', function() {
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result;
result = matcher.compare([1], [1]);
expect(result.pass).toBe(false);
- expect(result.message).toBe("Expected [ 1 ] to be [ 1 ]. Tip: To check for deep equality, use .toEqual() instead of .toBe().")
+ expect(result.message).toBe(
+ 'Expected [ 1 ] to be [ 1 ]. Tip: To check for deep equality, use .toEqual() instead of .toBe().'
+ );
});
- it("fails with a custom message when expected is an object", function() {
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
+ it('fails with a custom message when expected is an object', function() {
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result;
- result = matcher.compare({foo: "bar"}, {foo: "bar"});
+ result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
expect(result.pass).toBe(false);
- expect(result.message).toBe("Expected Object({ foo: 'bar' }) to be Object({ foo: 'bar' }). Tip: To check for deep equality, use .toEqual() instead of .toBe().")
+ expect(result.message).toBe(
+ "Expected Object({ foo: 'bar' }) to be Object({ foo: 'bar' }). Tip: To check for deep equality, use .toEqual() instead of .toBe()."
+ );
});
- it("works with custom object formatters when expected is an object", function() {
- var formatter = function(x) { return '<' + x.foo + '>'; },
+ it('works with custom object formatters when expected is an object', function() {
+ var formatter = function(x) {
+ return '<' + x.foo + '>';
+ },
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
- matchersUtil = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
+ matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: prettyPrinter }),
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
result;
- result = matcher.compare({foo: "bar"}, {foo: "bar"});
+ result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
expect(result.pass).toBe(false);
- expect(result.message).toBe("Expected <bar> to be <bar>. Tip: To check for deep equality, use .toEqual() instead of .toBe().")
+ expect(result.message).toBe(
+ 'Expected <bar> to be <bar>. Tip: To check for deep equality, use .toEqual() instead of .toBe().'
+ );
});
});
diff --git a/spec/core/matchers/toBeTrueSpec.js b/spec/core/matchers/toBeTrueSpec.js
index ceac207..d444d20 100644
--- a/spec/core/matchers/toBeTrueSpec.js
+++ b/spec/core/matchers/toBeTrueSpec.js
@@ -1,5 +1,5 @@
-describe("toBeTrue", function() {
- it("passes for true", function() {
+describe('toBeTrue', function() {
+ it('passes for true', function() {
var matcher = jasmineUnderTest.matchers.toBeTrue(),
result;
@@ -7,7 +7,7 @@
expect(result.pass).toBe(true);
});
- it("fails for non-true", function() {
+ it('fails for non-true', function() {
var matcher = jasmineUnderTest.matchers.toBeTrue(),
result;
diff --git a/spec/core/matchers/toBeTruthySpec.js b/spec/core/matchers/toBeTruthySpec.js
index 7d5f284..f7bb258 100644
--- a/spec/core/matchers/toBeTruthySpec.js
+++ b/spec/core/matchers/toBeTruthySpec.js
@@ -1,4 +1,4 @@
-describe("toBeTruthy", function() {
+describe('toBeTruthy', function() {
it("passes for 'truthy' values", function() {
var matcher = jasmineUnderTest.matchers.toBeTruthy(),
result;
@@ -9,7 +9,7 @@
result = matcher.compare(1);
expect(result.pass).toBe(true);
- result = matcher.compare("foo");
+ result = matcher.compare('foo');
expect(result.pass).toBe(true);
result = matcher.compare({});
diff --git a/spec/core/matchers/toBeUndefinedSpec.js b/spec/core/matchers/toBeUndefinedSpec.js
index c3588e3..f4c090f 100644
--- a/spec/core/matchers/toBeUndefinedSpec.js
+++ b/spec/core/matchers/toBeUndefinedSpec.js
@@ -1,18 +1,17 @@
-describe("toBeUndefined", function() {
- it("passes for undefined values", function() {
+describe('toBeUndefined', function() {
+ it('passes for undefined values', function() {
var matcher = jasmineUnderTest.matchers.toBeUndefined(),
result;
result = matcher.compare(void 0);
expect(result.pass).toBe(true);
-
});
- it("fails when matching defined values", function() {
+ it('fails when matching defined values', function() {
var matcher = jasmineUnderTest.matchers.toBeUndefined(),
result;
result = matcher.compare('foo');
expect(result.pass).toBe(false);
- })
+ });
});
diff --git a/spec/core/matchers/toContainSpec.js b/spec/core/matchers/toContainSpec.js
index 5fd1c8f..1feab6b 100644
--- a/spec/core/matchers/toContainSpec.js
+++ b/spec/core/matchers/toContainSpec.js
@@ -1,21 +1,23 @@
-describe("toContain", function() {
- it("delegates to jasmineUnderTest.matchersUtil.contains", function() {
+describe('toContain', function() {
+ it('delegates to jasmineUnderTest.matchersUtil.contains', function() {
var matchersUtil = {
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
},
matcher = jasmineUnderTest.matchers.toContain(matchersUtil),
result;
- result = matcher.compare("ABC", "B");
- expect(matchersUtil.contains).toHaveBeenCalledWith("ABC", "B");
+ result = matcher.compare('ABC', 'B');
+ expect(matchersUtil.contains).toHaveBeenCalledWith('ABC', 'B');
expect(result.pass).toBe(true);
});
- it("works with custom equality testers", function() {
- var tester = function (a, b) {
+ it('works with custom equality testers', function() {
+ var tester = function(a, b) {
return a.toString() === b.toString();
},
- matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [tester]}),
+ matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: [tester]
+ }),
matcher = jasmineUnderTest.matchers.toContain(matchersUtil),
result;
diff --git a/spec/core/matchers/toEqualSpec.js b/spec/core/matchers/toEqualSpec.js
index db7f3ff..b2fb9f9 100644
--- a/spec/core/matchers/toEqualSpec.js
+++ b/spec/core/matchers/toEqualSpec.js
@@ -1,5 +1,5 @@
-describe("toEqual", function() {
- "use strict";
+describe('toEqual', function() {
+ 'use strict';
function compareEquals(actual, expected) {
var matchersUtil = new jasmineUnderTest.MatchersUtil({
@@ -12,7 +12,7 @@
return result;
}
- it("delegates to equals function", function() {
+ it('delegates to equals function', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
buildFailureMessage: function() {
@@ -29,11 +29,13 @@
expect(result.pass).toBe(true);
});
- it("works with custom equality testers", function() {
- var tester = function (a, b) {
+ it('works with custom equality testers', function() {
+ var tester = function(a, b) {
return a.toString() === b.toString();
},
- matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [tester]}),
+ matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: [tester]
+ }),
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
result;
@@ -42,300 +44,297 @@
expect(result.pass).toBe(true);
});
- it("reports the difference between objects that are not equal", function() {
- var actual = {x: 1, y: 3},
- expected = {x: 2, y: 3},
- message = "Expected $.x = 1 to equal 2.";
+ it('reports the difference between objects that are not equal', function() {
+ var actual = { x: 1, y: 3 },
+ expected = { x: 2, y: 3 },
+ message = 'Expected $.x = 1 to equal 2.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports the difference between nested objects that are not equal", function() {
- var actual = {x: {y: 1}},
- expected = {x: {y: 2}},
- message = "Expected $.x.y = 1 to equal 2.";
+ it('reports the difference between nested objects that are not equal', function() {
+ var actual = { x: { y: 1 } },
+ expected = { x: { y: 2 } },
+ message = 'Expected $.x.y = 1 to equal 2.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
it("formats property access so that it's valid JavaScript", function() {
- var actual = {'my prop': 1},
- expected = {'my prop': 2},
+ var actual = { 'my prop': 1 },
+ expected = { 'my prop': 2 },
message = "Expected $['my prop'] = 1 to equal 2.";
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports missing properties", function() {
- var actual = {x: {}},
- expected = {x: {y: 1}},
- message =
- "Expected $.x to have properties\n" +
- " y: 1";
+ it('reports missing properties', function() {
+ var actual = { x: {} },
+ expected = { x: { y: 1 } },
+ message = 'Expected $.x to have properties\n' + ' y: 1';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports extra properties", function() {
- var actual = {x: {y: 1, z: 2}},
- expected = {x: {}},
+ it('reports extra properties', function() {
+ var actual = { x: { y: 1, z: 2 } },
+ expected = { x: {} },
message =
- "Expected $.x not to have properties\n" +
- " y: 1\n" +
- " z: 2";
+ 'Expected $.x not to have properties\n' + ' y: 1\n' + ' z: 2';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("pretty-prints properties", function() {
- var actual = {x: {y: 'foo bar'}},
- expected = {x: {}},
- message =
- "Expected $.x not to have properties\n" +
- " y: 'foo bar'";
+ it('pretty-prints properties', function() {
+ var actual = { x: { y: 'foo bar' } },
+ expected = { x: {} },
+ message = 'Expected $.x not to have properties\n' + " y: 'foo bar'";
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("uses custom object formatters to pretty-print simple properties", function() {
+ it('uses custom object formatters to pretty-print simple properties', function() {
function formatter(x) {
if (typeof x === 'number') {
return '|' + x + '|';
}
}
- var actual = {x: {y: 1, z: 2, f: 4}},
- expected = {x: {y: 1, z: 2, g: 3}},
+ var actual = { x: { y: 1, z: 2, f: 4 } },
+ expected = { x: { y: 1, z: 2, g: 3 } },
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
- matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
+ matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
message =
- "Expected $.x to have properties\n" +
- " g: |3|\n" +
- "Expected $.x not to have properties\n" +
- " f: |4|";
+ 'Expected $.x to have properties\n' +
+ ' g: |3|\n' +
+ 'Expected $.x not to have properties\n' +
+ ' f: |4|';
expect(matcher.compare(actual, expected).message).toEqual(message);
});
- it("uses custom object formatters to show simple values in diffs", function() {
+ it('uses custom object formatters to show simple values in diffs', function() {
function formatter(x) {
if (typeof x === 'number') {
return '|' + x + '|';
}
}
- var actual = [{foo: 4}],
- expected = [{foo: 5}],
+ var actual = [{ foo: 4 }],
+ expected = [{ foo: 5 }],
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
- matchersUtil = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
+ matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: prettyPrinter }),
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
- message = "Expected $[0].foo = |4| to equal |5|.";
+ message = 'Expected $[0].foo = |4| to equal |5|.';
expect(matcher.compare(actual, expected).message).toEqual(message);
});
- it("uses custom object formatters to show more complex objects diffs", function() {
+ it('uses custom object formatters to show more complex objects diffs', function() {
function formatter(x) {
if (x.hasOwnProperty('a')) {
return '[thing with a=' + x.a + ', b=' + x.b + ']';
}
}
- var actual = [{
- foo: {a: 1, b: 2},
- bar: 'should not be pretty printed'
- }],
- expected = [{
- foo: {a: 5, b: 2},
- bar: "shouldn't be pretty printed"
- }],
+ var actual = [
+ {
+ foo: { a: 1, b: 2 },
+ bar: 'should not be pretty printed'
+ }
+ ],
+ expected = [
+ {
+ foo: { a: 5, b: 2 },
+ bar: "shouldn't be pretty printed"
+ }
+ ],
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
- matchersUtil = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
+ matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: prettyPrinter }),
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
- message = "Expected $[0].foo = [thing with a=1, b=2] to equal [thing with a=5, b=2].\n" +
+ message =
+ 'Expected $[0].foo = [thing with a=1, b=2] to equal [thing with a=5, b=2].\n' +
"Expected $[0].bar = 'should not be pretty printed' to equal 'shouldn't be pretty printed'.";
expect(matcher.compare(actual, expected).message).toEqual(message);
});
- it("reports extra and missing properties of the root-level object", function() {
- var actual = {x: 1},
- expected = {a: 1},
+ it('reports extra and missing properties of the root-level object', function() {
+ var actual = { x: 1 },
+ expected = { a: 1 },
message =
- "Expected object to have properties\n" +
- " a: 1\n" +
- "Expected object not to have properties\n" +
- " x: 1";
+ 'Expected object to have properties\n' +
+ ' a: 1\n' +
+ 'Expected object not to have properties\n' +
+ ' x: 1';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports multiple incorrect values", function() {
- var actual = {x: 1, y: 2},
- expected = {x: 3, y: 4},
+ it('reports multiple incorrect values', function() {
+ var actual = { x: 1, y: 2 },
+ expected = { x: 3, y: 4 },
message =
- "Expected $.x = 1 to equal 3.\n" +
- "Expected $.y = 2 to equal 4.";
+ 'Expected $.x = 1 to equal 3.\n' + 'Expected $.y = 2 to equal 4.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatch between actual child object and expected child number", function() {
- var actual = {x: {y: 2}},
- expected = {x: 1},
- message = "Expected $.x = Object({ y: 2 }) to equal 1.";
+ it('reports mismatch between actual child object and expected child number', function() {
+ var actual = { x: { y: 2 } },
+ expected = { x: 1 },
+ message = 'Expected $.x = Object({ y: 2 }) to equal 1.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("uses the default failure message if actual is not an object", function() {
+ it('uses the default failure message if actual is not an object', function() {
var actual = 1,
- expected = {x: {}},
- message = "Expected 1 to equal Object({ x: Object({ }) }).";
+ expected = { x: {} },
+ message = 'Expected 1 to equal Object({ x: Object({ }) }).';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("uses the default failure message if expected is not an object", function() {
- var actual = {x: {}},
+ it('uses the default failure message if expected is not an object', function() {
+ var actual = { x: {} },
expected = 1,
- message = "Expected Object({ x: Object({ }) }) to equal 1.";
+ message = 'Expected Object({ x: Object({ }) }) to equal 1.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("uses the default failure message given arrays with different lengths", function() {
+ it('uses the default failure message given arrays with different lengths', function() {
var actual = [1, 2],
expected = [1, 2, 3],
- message = 'Expected $.length = 2 to equal 3.\n' +
+ message =
+ 'Expected $.length = 2 to equal 3.\n' +
'Expected $[2] = undefined to equal 3.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports a mismatch between elements of equal-length arrays", function() {
+ it('reports a mismatch between elements of equal-length arrays', function() {
var actual = [1, 2, 5],
expected = [1, 2, 3],
- message = "Expected $[2] = 5 to equal 3.";
+ message = 'Expected $[2] = 5 to equal 3.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports a mismatch between multiple array elements", function() {
+ it('reports a mismatch between multiple array elements', function() {
var actual = [2, 2, 5],
expected = [1, 2, 3],
message =
- "Expected $[0] = 2 to equal 1.\n" +
- "Expected $[2] = 5 to equal 3.";
+ 'Expected $[0] = 2 to equal 1.\n' + 'Expected $[2] = 5 to equal 3.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports a mismatch between properties of objects in arrays", function() {
- var actual = [{x: 1}],
- expected = [{x: 2}],
- message = "Expected $[0].x = 1 to equal 2.";
+ it('reports a mismatch between properties of objects in arrays', function() {
+ var actual = [{ x: 1 }],
+ expected = [{ x: 2 }],
+ message = 'Expected $[0].x = 1 to equal 2.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports a mismatch between arrays in objects", function() {
- var actual = {x: [1]},
- expected = {x: [2]},
- message =
- "Expected $.x[0] = 1 to equal 2.";
+ it('reports a mismatch between arrays in objects', function() {
+ var actual = { x: [1] },
+ expected = { x: [2] },
+ message = 'Expected $.x[0] = 1 to equal 2.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between nested arrays", function() {
+ it('reports mismatches between nested arrays', function() {
var actual = [[1]],
expected = [[2]],
- message =
- "Expected $[0][0] = 1 to equal 2.";
+ message = 'Expected $[0][0] = 1 to equal 2.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between arrays of different types", function() {
+ it('reports mismatches between arrays of different types', function() {
jasmine.getEnv().requireFunctioningTypedArrays();
var actual = new Uint32Array([1, 2, 3]), // eslint-disable-line compat/compat
expected = new Uint16Array([1, 2, 3]), // eslint-disable-line compat/compat
- message = "Expected Uint32Array [ 1, 2, 3 ] to equal Uint16Array [ 1, 2, 3 ].";
+ message =
+ 'Expected Uint32Array [ 1, 2, 3 ] to equal Uint16Array [ 1, 2, 3 ].';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches involving NaN", function() {
- var actual = {x: 0},
- expected = {x: 0/0},
- message = "Expected $.x = 0 to equal NaN.";
+ it('reports mismatches involving NaN', function() {
+ var actual = { x: 0 },
+ expected = { x: 0 / 0 },
+ message = 'Expected $.x = 0 to equal NaN.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches involving regular expressions", function() {
- var actual = {x: '1'},
- expected = {x: /1/},
+ it('reports mismatches involving regular expressions', function() {
+ var actual = { x: '1' },
+ expected = { x: /1/ },
message = "Expected $.x = '1' to equal /1/.";
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches involving infinities", function() {
- var actual = {x: 0},
- expected = {x: 1/0},
- message = "Expected $.x = 0 to equal Infinity.";
+ it('reports mismatches involving infinities', function() {
+ var actual = { x: 0 },
+ expected = { x: 1 / 0 },
+ message = 'Expected $.x = 0 to equal Infinity.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches involving booleans", function() {
- var actual = {x: false},
- expected = {x: true},
- message = "Expected $.x = false to equal true.";
+ it('reports mismatches involving booleans', function() {
+ var actual = { x: false },
+ expected = { x: true },
+ message = 'Expected $.x = false to equal true.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches involving strings", function() {
- var actual = {x: 'foo'},
- expected = {x: 'bar'},
+ it('reports mismatches involving strings', function() {
+ var actual = { x: 'foo' },
+ expected = { x: 'bar' },
message = "Expected $.x = 'foo' to equal 'bar'.";
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches involving undefined", function() {
- var actual = {x: void 0},
- expected = {x: 0},
- message = "Expected $.x = undefined to equal 0.";
+ it('reports mismatches involving undefined', function() {
+ var actual = { x: void 0 },
+ expected = { x: 0 },
+ message = 'Expected $.x = undefined to equal 0.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches involving null", function() {
- var actual = {x: null},
- expected = {x: 0},
- message = "Expected $.x = null to equal 0.";
+ it('reports mismatches involving null', function() {
+ var actual = { x: null },
+ expected = { x: 0 },
+ message = 'Expected $.x = null to equal 0.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between objects with different constructors", function () {
+ it('reports mismatches between objects with different constructors', function() {
function Foo() {}
function Bar() {}
- var actual = {x: new Foo()},
- expected = {x: new Bar()},
- message = "Expected $.x to be a kind of Bar, but was Foo({ }).";
+ var actual = { x: new Foo() },
+ expected = { x: new Bar() },
+ message = 'Expected $.x to be a kind of Bar, but was Foo({ }).';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("uses custom object formatters for the value but not the type when reporting objects with different constructors", function () {
+ it('uses custom object formatters for the value but not the type when reporting objects with different constructors', function() {
function Foo() {}
function Bar() {}
function formatter(x) {
@@ -344,52 +343,50 @@
}
}
- var actual = {x: new Foo()},
- expected = {x: new Bar()},
- message = "Expected $.x to be a kind of Bar, but was |[object Object]|.",
+ var actual = { x: new Foo() },
+ expected = { x: new Bar() },
+ message = 'Expected $.x to be a kind of Bar, but was |[object Object]|.',
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
- matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
+ matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil);
expect(matcher.compare(actual, expected).message).toEqual(message);
});
- it("reports type mismatches at the root level", function () {
+ it('reports type mismatches at the root level', function() {
function Foo() {}
function Bar() {}
var actual = new Foo(),
expected = new Bar(),
- message = "Expected object to be a kind of Bar, but was Foo({ }).";
+ message = 'Expected object to be a kind of Bar, but was Foo({ }).';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports value mismatches at the root level", function() {
- expect(compareEquals(1, 2).message).toEqual("Expected 1 to equal 2.");
+ it('reports value mismatches at the root level', function() {
+ expect(compareEquals(1, 2).message).toEqual('Expected 1 to equal 2.');
});
-
- it("reports mismatches between objects with their own constructor property", function () {
+ it('reports mismatches between objects with their own constructor property', function() {
function Foo() {}
function Bar() {}
- var actual = {x: {constructor: 'blerf'}},
- expected = {x: {constructor: 'ftarrh'}},
- message = "Expected $.x.constructor = 'blerf' to equal 'ftarrh'.";
+ var actual = { x: { constructor: 'blerf' } },
+ expected = { x: { constructor: 'ftarrh' } },
+ message = "Expected $.x.constructor = 'blerf' to equal 'ftarrh'.";
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between an object with a real constructor and one with its own constructor property", function () {
+ it('reports mismatches between an object with a real constructor and one with its own constructor property', function() {
function Foo() {}
function Bar() {}
- var actual = {x: {}},
- expected = {x: {constructor: 'ftarrh'}},
+ var actual = { x: {} },
+ expected = { x: { constructor: 'ftarrh' } },
message =
- "Expected $.x to have properties\n" +
- " constructor: 'ftarrh'";
+ 'Expected $.x to have properties\n' + " constructor: 'ftarrh'";
expect(compareEquals(actual, expected).message).toEqual(message);
expect(compareEquals(expected, actual).message).toEqual(
@@ -397,68 +394,74 @@
);
});
- it("reports mismatches between 0 and -0", function() {
- var actual = {x: 0},
- expected = {x: -0},
- message = "Expected $.x = 0 to equal -0.";
+ it('reports mismatches between 0 and -0', function() {
+ var actual = { x: 0 },
+ expected = { x: -0 },
+ message = 'Expected $.x = 0 to equal -0.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between 0 and Number.MIN_VALUE", function() {
- var actual = {x: 0},
- expected = {x: Number.MIN_VALUE},
- message = "Expected $.x = 0 to equal 5e-324.";
+ it('reports mismatches between 0 and Number.MIN_VALUE', function() {
+ var actual = { x: 0 },
+ expected = { x: Number.MIN_VALUE },
+ message = 'Expected $.x = 0 to equal 5e-324.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between Errors", function() {
- var actual = {x: new Error("the error you got")},
- expected = {x: new Error("the error you want")},
- message = "Expected $.x = Error: the error you got to equal Error: the error you want.";
+ it('reports mismatches between Errors', function() {
+ var actual = { x: new Error('the error you got') },
+ expected = { x: new Error('the error you want') },
+ message =
+ 'Expected $.x = Error: the error you got to equal Error: the error you want.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between Functions", function() {
- var actual = {x: function() {}},
- expected = {x: function() {}},
- message = "Expected $.x = Function to equal Function.";
+ it('reports mismatches between Functions', function() {
+ var actual = { x: function() {} },
+ expected = { x: function() {} },
+ message = 'Expected $.x = Function to equal Function.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
it('reports mismatches between an object and objectContaining', function() {
- var actual = {a: 1, b: 4, c: 3, extra: 'ignored'};
- var expected = jasmineUnderTest.objectContaining({a: 1, b: 2, c: 3, d: 4});
- expect(compareEquals(actual, expected).message)
- .toEqual(
- 'Expected $.b = 4 to equal 2.\n' +
- 'Expected $.d = undefined to equal 4.'
- );
+ var actual = { a: 1, b: 4, c: 3, extra: 'ignored' };
+ var expected = jasmineUnderTest.objectContaining({
+ a: 1,
+ b: 2,
+ c: 3,
+ d: 4
+ });
+ expect(compareEquals(actual, expected).message).toEqual(
+ 'Expected $.b = 4 to equal 2.\n' + 'Expected $.d = undefined to equal 4.'
+ );
});
- it("reports mismatches between a non-object and objectContaining", function() {
+ it('reports mismatches between a non-object and objectContaining', function() {
var actual = 1;
- var expected = jasmineUnderTest.objectContaining({a: 1});
+ var expected = jasmineUnderTest.objectContaining({ a: 1 });
expect(compareEquals(actual, expected).message).toEqual(
"Expected 1 to equal '<jasmine.objectContaining(Object({ a: 1 }))>'."
);
});
- it("reports mismatches involving a nested objectContaining", function() {
- var actual = {x: {a: 1, b: 4, c: 3, extra: 'ignored'}};
- var expected = {x: jasmineUnderTest.objectContaining({a: 1, b: 2, c: 3, d: 4})};
+ it('reports mismatches involving a nested objectContaining', function() {
+ var actual = { x: { a: 1, b: 4, c: 3, extra: 'ignored' } };
+ var expected = {
+ x: jasmineUnderTest.objectContaining({ a: 1, b: 2, c: 3, d: 4 })
+ };
expect(compareEquals(actual, expected).message).toEqual(
'Expected $.x.b = 4 to equal 2.\n' +
- 'Expected $.x.d = undefined to equal 4.'
+ 'Expected $.x.d = undefined to equal 4.'
);
});
// == Sets ==
- it("reports mismatches between Sets", function() {
+ it('reports mismatches between Sets', function() {
jasmine.getEnv().requireFunctioningSets();
var actual = new Set(); // eslint-disable-line compat/compat
@@ -470,19 +473,20 @@
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports deep mismatches within Sets", function() {
+ it('reports deep mismatches within Sets', function() {
jasmine.getEnv().requireFunctioningSets();
var actual = new Set(); // eslint-disable-line compat/compat
- actual.add({x: 1});
+ actual.add({ x: 1 });
var expected = new Set(); // eslint-disable-line compat/compat
- expected.add({x: 2});
- var message = 'Expected Set( Object({ x: 1 }) ) to equal Set( Object({ x: 2 }) ).';
+ expected.add({ x: 2 });
+ var message =
+ 'Expected Set( Object({ x: 1 }) ) to equal Set( Object({ x: 2 }) ).';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between Sets nested in objects", function() {
+ it('reports mismatches between Sets nested in objects', function() {
jasmine.getEnv().requireFunctioningSets();
var actualSet = new Set(); // eslint-disable-line compat/compat
@@ -492,12 +496,12 @@
var actual = { sets: [actualSet] };
var expected = { sets: [expectedSet] };
- var message = "Expected $.sets[0] = Set( 1 ) to equal Set( 2 ).";
+ var message = 'Expected $.sets[0] = Set( 1 ) to equal Set( 2 ).';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between Sets of different lengths", function() {
+ it('reports mismatches between Sets of different lengths', function() {
jasmine.getEnv().requireFunctioningSets();
var actual = new Set(); // eslint-disable-line compat/compat
@@ -510,175 +514,182 @@
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between Sets where actual is missing a value from expected", function() {
+ it('reports mismatches between Sets where actual is missing a value from expected', function() {
jasmine.getEnv().requireFunctioningSets();
// Use 'duplicate' object in actual so sizes match
var actual = new Set(); // eslint-disable-line compat/compat
- actual.add({x: 1});
- actual.add({x: 1});
+ actual.add({ x: 1 });
+ actual.add({ x: 1 });
var expected = new Set(); // eslint-disable-line compat/compat
- expected.add({x: 1});
- expected.add({x: 2});
- var message = 'Expected Set( Object({ x: 1 }), Object({ x: 1 }) ) to equal Set( Object({ x: 1 }), Object({ x: 2 }) ).';
+ expected.add({ x: 1 });
+ expected.add({ x: 2 });
+ var message =
+ 'Expected Set( Object({ x: 1 }), Object({ x: 1 }) ) to equal Set( Object({ x: 1 }), Object({ x: 2 }) ).';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between Sets where actual has a value missing from expected", function() {
+ it('reports mismatches between Sets where actual has a value missing from expected', function() {
jasmine.getEnv().requireFunctioningSets();
// Use 'duplicate' object in expected so sizes match
var actual = new Set(); // eslint-disable-line compat/compat
- actual.add({x: 1});
- actual.add({x: 2});
+ actual.add({ x: 1 });
+ actual.add({ x: 2 });
var expected = new Set(); // eslint-disable-line compat/compat
- expected.add({x: 1});
- expected.add({x: 1});
- var message = 'Expected Set( Object({ x: 1 }), Object({ x: 2 }) ) to equal Set( Object({ x: 1 }), Object({ x: 1 }) ).';
+ expected.add({ x: 1 });
+ expected.add({ x: 1 });
+ var message =
+ 'Expected Set( Object({ x: 1 }), Object({ x: 2 }) ) to equal Set( Object({ x: 1 }), Object({ x: 1 }) ).';
expect(compareEquals(actual, expected).message).toEqual(message);
});
// == Maps ==
- it("does not report mismatches between deep equal Maps", function() {
+ it('does not report mismatches between deep equal Maps', function() {
jasmine.getEnv().requireFunctioningMaps();
// values are the same but with different object identity
var actual = new Map(); // eslint-disable-line compat/compat
- actual.set('a',{x:1});
+ actual.set('a', { x: 1 });
var expected = new Map(); // eslint-disable-line compat/compat
- expected.set('a',{x:1});
+ expected.set('a', { x: 1 });
expect(compareEquals(actual, expected).pass).toBe(true);
});
- it("reports deep mismatches within Maps", function() {
+ it('reports deep mismatches within Maps', function() {
jasmine.getEnv().requireFunctioningMaps();
var actual = new Map(); // eslint-disable-line compat/compat
- actual.set('a',{x:1});
+ actual.set('a', { x: 1 });
var expected = new Map(); // eslint-disable-line compat/compat
- expected.set('a',{x:2});
- var message = "Expected Map( [ 'a', Object({ x: 1 }) ] ) to equal Map( [ 'a', Object({ x: 2 }) ] ).";
+ expected.set('a', { x: 2 });
+ var message =
+ "Expected Map( [ 'a', Object({ x: 1 }) ] ) to equal Map( [ 'a', Object({ x: 2 }) ] ).";
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between Maps nested in objects", function() {
+ it('reports mismatches between Maps nested in objects', function() {
jasmine.getEnv().requireFunctioningMaps();
- var actual = {Maps:[new Map()]}; // eslint-disable-line compat/compat
- actual.Maps[0].set('a',1);
- var expected = {Maps:[new Map()]}; // eslint-disable-line compat/compat
- expected.Maps[0].set('a',2);
+ var actual = { Maps: [new Map()] }; // eslint-disable-line compat/compat
+ actual.Maps[0].set('a', 1);
+ var expected = { Maps: [new Map()] }; // eslint-disable-line compat/compat
+ expected.Maps[0].set('a', 2);
- var message = "Expected $.Maps[0] = Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ] ).";
+ var message =
+ "Expected $.Maps[0] = Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ] ).";
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between Maps of different lengths", function() {
+ it('reports mismatches between Maps of different lengths', function() {
jasmine.getEnv().requireFunctioningMaps();
var actual = new Map(); // eslint-disable-line compat/compat
- actual.set('a',1);
+ actual.set('a', 1);
var expected = new Map(); // eslint-disable-line compat/compat
- expected.set('a',2);
- expected.set('b',1);
- var message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ], [ 'b', 1 ] ).";
+ expected.set('a', 2);
+ expected.set('b', 1);
+ var message =
+ "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'a', 2 ], [ 'b', 1 ] ).";
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between Maps with equal values but differing keys", function() {
+ it('reports mismatches between Maps with equal values but differing keys', function() {
jasmine.getEnv().requireFunctioningMaps();
var actual = new Map(); // eslint-disable-line compat/compat
- actual.set('a',1);
+ actual.set('a', 1);
var expected = new Map(); // eslint-disable-line compat/compat
- expected.set('b',1);
+ expected.set('b', 1);
var message = "Expected Map( [ 'a', 1 ] ) to equal Map( [ 'b', 1 ] ).";
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("does not report mismatches between Maps with keys with same object identity", function() {
+ it('does not report mismatches between Maps with keys with same object identity', function() {
jasmine.getEnv().requireFunctioningMaps();
- var key = {x: 1};
+ var key = { x: 1 };
var actual = new Map(); // eslint-disable-line compat/compat
- actual.set(key,2);
+ actual.set(key, 2);
var expected = new Map(); // eslint-disable-line compat/compat
- expected.set(key,2);
+ expected.set(key, 2);
expect(compareEquals(actual, expected).pass).toBe(true);
});
- it("reports mismatches between Maps with identical keys with different object identity", function() {
+ it('reports mismatches between Maps with identical keys with different object identity', function() {
jasmine.getEnv().requireFunctioningMaps();
var actual = new Map(); // eslint-disable-line compat/compat
- actual.set({x:1},2);
+ actual.set({ x: 1 }, 2);
var expected = new Map(); // eslint-disable-line compat/compat
- expected.set({x:1},2);
- var message = "Expected Map( [ Object({ x: 1 }), 2 ] ) to equal Map( [ Object({ x: 1 }), 2 ] ).";
+ expected.set({ x: 1 }, 2);
+ var message =
+ 'Expected Map( [ Object({ x: 1 }), 2 ] ) to equal Map( [ Object({ x: 1 }), 2 ] ).';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("does not report mismatches when comparing Map key to jasmine.anything()", function() {
+ it('does not report mismatches when comparing Map key to jasmine.anything()', function() {
jasmine.getEnv().requireFunctioningMaps();
var actual = new Map(); // eslint-disable-line compat/compat
- actual.set('a',1);
+ actual.set('a', 1);
var expected = new Map(); // eslint-disable-line compat/compat
- expected.set(jasmineUnderTest.anything(),1);
+ expected.set(jasmineUnderTest.anything(), 1);
expect(compareEquals(actual, expected).pass).toBe(true);
});
- it("does not report mismatches when comparing Maps with the same symbol keys", function() {
+ it('does not report mismatches when comparing Maps with the same symbol keys', function() {
jasmine.getEnv().requireFunctioningMaps();
jasmine.getEnv().requireFunctioningSymbols();
var key = Symbol(); // eslint-disable-line compat/compat
var actual = new Map(); // eslint-disable-line compat/compat
- actual.set(key,1);
+ actual.set(key, 1);
var expected = new Map(); // eslint-disable-line compat/compat
- expected.set(key,1);
+ expected.set(key, 1);
expect(compareEquals(actual, expected).pass).toBe(true);
});
- it("reports mismatches between Maps with different symbol keys", function() {
+ it('reports mismatches between Maps with different symbol keys', function() {
jasmine.getEnv().requireFunctioningMaps();
jasmine.getEnv().requireFunctioningSymbols();
var actual = new Map(); // eslint-disable-line compat/compat
- actual.set(Symbol(),1); // eslint-disable-line compat/compat
+ actual.set(Symbol(), 1); // eslint-disable-line compat/compat
var expected = new Map(); // eslint-disable-line compat/compat
- expected.set(Symbol(),1); // eslint-disable-line compat/compat
- var message = "Expected Map( [ Symbol(), 1 ] ) to equal Map( [ Symbol(), 1 ] ).";
+ expected.set(Symbol(), 1); // eslint-disable-line compat/compat
+ var message =
+ 'Expected Map( [ Symbol(), 1 ] ) to equal Map( [ Symbol(), 1 ] ).';
expect(compareEquals(actual, expected).message).toBe(message);
});
- it("does not report mismatches when comparing Map symbol key to jasmine.anything()", function() {
+ it('does not report mismatches when comparing Map symbol key to jasmine.anything()', function() {
jasmine.getEnv().requireFunctioningMaps();
jasmine.getEnv().requireFunctioningSymbols();
var actual = new Map(); // eslint-disable-line compat/compat
- actual.set(Symbol(),1); // eslint-disable-line compat/compat
+ actual.set(Symbol(), 1); // eslint-disable-line compat/compat
var expected = new Map(); // eslint-disable-line compat/compat
- expected.set(jasmineUnderTest.anything(),1);
+ expected.set(jasmineUnderTest.anything(), 1);
expect(compareEquals(actual, expected).pass).toBe(true);
});
describe('DOM nodes', function() {
function isNotRunningInBrowser() {
- return typeof document === 'undefined'
+ return typeof document === 'undefined';
}
beforeEach(function() {
@@ -699,30 +710,31 @@
}
});
- it("reports mismatches between DOM nodes with different tags", function() {
- var actual = {a: this.doc.createElement('div')},
- expected = {a: this.doc.createElement('p')},
- message = 'Expected $.a = <div> to equal <p>.';
+ it('reports mismatches between DOM nodes with different tags', function() {
+ var actual = { a: this.doc.createElement('div') },
+ expected = { a: this.doc.createElement('p') },
+ message = 'Expected $.a = <div> to equal <p>.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
it('reports mismatches between DOM nodes with different content', function() {
var nodeA = this.doc.createElement('div'),
- nodeB = this.doc.createElement('div');
+ nodeB = this.doc.createElement('div');
nodeA.setAttribute('thing', 'foo');
nodeB.setAttribute('thing', 'bar');
expect(nodeA.isEqualNode(nodeB)).toBe(false);
- var actual = {a: nodeA},
- expected = {a: nodeB},
- message = 'Expected $.a = <div thing="foo"> to equal <div thing="bar">.';
+ var actual = { a: nodeA },
+ expected = { a: nodeB },
+ message =
+ 'Expected $.a = <div thing="foo"> to equal <div thing="bar">.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between SVG nodes", function () {
+ it('reports mismatches between SVG nodes', function() {
var nodeA = this.doc.createElementNS('http://www.w3.org/2000/svg', 'svg'),
nodeB = this.doc.createElementNS('http://www.w3.org/2000/svg', 'svg');
@@ -734,14 +746,15 @@
nodeA.appendChild(rect);
expect(nodeA.isEqualNode(nodeB)).toBe(false);
- var actual = {a: nodeA},
- expected = {a: nodeB},
- message = 'Expected $.a = <svg height="50">...</svg> to equal <svg height="30">.';
+ var actual = { a: nodeA },
+ expected = { a: nodeB },
+ message =
+ 'Expected $.a = <svg height="50">...</svg> to equal <svg height="30">.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports whole DOM node when attribute contains > character", function () {
+ it('reports whole DOM node when attribute contains > character', function() {
var nodeA = this.doc.createElement('div'),
nodeB = this.doc.createElement('div');
@@ -749,14 +762,15 @@
nodeB.setAttribute('thing', 'bar');
expect(nodeA.isEqualNode(nodeB)).toBe(false);
- var actual = {a: nodeA},
- expected = {a: nodeB},
- message = 'Expected $.a = <div thing=">>>"> to equal <div thing="bar">.';
+ var actual = { a: nodeA },
+ expected = { a: nodeB },
+ message =
+ 'Expected $.a = <div thing=">>>"> to equal <div thing="bar">.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it('reports no content when DOM node has multiple empty text nodes', function () {
+ it('reports no content when DOM node has multiple empty text nodes', function() {
var nodeA = this.doc.createElement('div'),
nodeB = this.doc.createElement('div');
@@ -766,103 +780,98 @@
nodeA.appendChild(this.doc.createTextNode(''));
expect(nodeA.isEqualNode(nodeB)).toBe(false);
- var actual = {a: nodeA},
- expected = {a: nodeB},
+ var actual = { a: nodeA },
+ expected = { a: nodeB },
message = 'Expected $.a = <div> to equal <div>.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it('reports content when DOM node has non empty text node', function () {
+ it('reports content when DOM node has non empty text node', function() {
var nodeA = this.doc.createElement('div'),
nodeB = this.doc.createElement('div');
nodeA.appendChild(this.doc.createTextNode('Hello Jasmine!'));
expect(nodeA.isEqualNode(nodeB)).toBe(false);
- var actual = {a: nodeA},
- expected = {a: nodeB},
+ var actual = { a: nodeA },
+ expected = { a: nodeB },
message = 'Expected $.a = <div>...</div> to equal <div>.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it('reports empty DOM attributes', function () {
+ it('reports empty DOM attributes', function() {
var nodeA = this.doc.createElement('div'),
nodeB = this.doc.createElement('div');
nodeA.setAttribute('contenteditable', '');
expect(nodeA.isEqualNode(nodeB)).toBe(false);
- var actual = {a: nodeA},
- expected = {a: nodeB},
+ var actual = { a: nodeA },
+ expected = { a: nodeB },
message = 'Expected $.a = <div contenteditable> to equal <div>.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it('reports 0 attr value as non empty DOM attribute', function () {
+ it('reports 0 attr value as non empty DOM attribute', function() {
var nodeA = this.doc.createElement('div'),
nodeB = this.doc.createElement('div');
nodeA.setAttribute('contenteditable', 0);
expect(nodeA.isEqualNode(nodeB)).toBe(false);
- var actual = {a: nodeA},
- expected = {a: nodeB},
+ var actual = { a: nodeA },
+ expected = { a: nodeB },
message = 'Expected $.a = <div contenteditable="0"> to equal <div>.';
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("reports mismatches between a DOM node and a bare Object", function() {
- var actual = {a: this.doc.createElement('div')},
- expected = {a: {}},
- message = 'Expected $.a = <div> to equal Object({ }).';
+ it('reports mismatches between a DOM node and a bare Object', function() {
+ var actual = { a: this.doc.createElement('div') },
+ expected = { a: {} },
+ message = 'Expected $.a = <div> to equal Object({ }).';
expect(compareEquals(actual, expected).message).toEqual(message);
});
});
- it("reports asymmetric mismatches", function() {
- var actual = {a: 1},
- expected = {a: jasmineUnderTest.any(String)},
+ it('reports asymmetric mismatches', function() {
+ var actual = { a: 1 },
+ expected = { a: jasmineUnderTest.any(String) },
message = 'Expected $.a = 1 to equal <jasmine.any(String)>.';
expect(compareEquals(actual, expected).message).toEqual(message);
- expect(compareEquals(actual, expected).pass).toBe(false)
+ expect(compareEquals(actual, expected).pass).toBe(false);
});
- it("reports asymmetric mismatches when the asymmetric comparand is the actual value", function() {
- var actual = {a: jasmineUnderTest.any(String)},
- expected = {a: 1},
+ it('reports asymmetric mismatches when the asymmetric comparand is the actual value', function() {
+ var actual = { a: jasmineUnderTest.any(String) },
+ expected = { a: 1 },
message = 'Expected $.a = <jasmine.any(String)> to equal 1.';
expect(compareEquals(actual, expected).message).toEqual(message);
- expect(compareEquals(actual, expected).pass).toBe(false)
+ expect(compareEquals(actual, expected).pass).toBe(false);
});
- it("does not report a mismatch when asymmetric matchers are satisfied", function() {
- var actual = {a: 'a'},
- expected = {a: jasmineUnderTest.any(String)};
+ it('does not report a mismatch when asymmetric matchers are satisfied', function() {
+ var actual = { a: 'a' },
+ expected = { a: jasmineUnderTest.any(String) };
expect(compareEquals(actual, expected).message).toEqual('');
- expect(compareEquals(actual, expected).pass).toBe(true)
+ expect(compareEquals(actual, expected).pass).toBe(true);
});
- it("works on big complex stuff", function() {
+ it('works on big complex stuff', function() {
var actual = {
- foo: [
- {bar: 1, things: ['a', 'b']},
- {bar: 2, things: ['a', 'b']}
- ],
- baz: [
- {a: {b: 1}}
- ],
+ foo: [{ bar: 1, things: ['a', 'b'] }, { bar: 2, things: ['a', 'b'] }],
+ baz: [{ a: { b: 1 } }],
quux: 1,
nan: 0,
aRegexp: 'hi',
- inf: -1/0,
+ inf: -1 / 0,
boolean: false,
notDefined: 0,
aNull: void 0
@@ -870,16 +879,14 @@
var expected = {
foo: [
- {bar: 2, things: ['a', 'b', 'c']},
- {bar: 2, things: ['a', 'd']}
+ { bar: 2, things: ['a', 'b', 'c'] },
+ { bar: 2, things: ['a', 'd'] }
],
- baz: [
- {a: {b: 1, c: 1}}
- ],
+ baz: [{ a: { b: 1, c: 1 } }],
quux: [],
- nan: 0/0,
+ nan: 0 / 0,
aRegexp: /hi/,
- inf: 1/0,
+ inf: 1 / 0,
boolean: true,
notDefined: void 0,
aNull: null
@@ -903,18 +910,19 @@
expect(compareEquals(actual, expected).message).toEqual(message);
});
- describe("different length arrays", function() {
- it("actual array is longer", function() {
+ describe('different length arrays', function() {
+ it('actual array is longer', function() {
var actual = [1, 1, 2, 3, 5],
expected = [1, 1, 2, 3],
- message = 'Expected $.length = 5 to equal 4.\n' +
+ message =
+ 'Expected $.length = 5 to equal 4.\n' +
'Unexpected $[4] = 5 in array.';
expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("uses custom object formatters when the actual array is longer", function() {
+ it('uses custom object formatters when the actual array is longer', function() {
function formatter(x) {
if (typeof x === 'number') {
return '|' + x + '|';
@@ -924,25 +932,27 @@
var actual = [1, 1, 2, 3, 5],
expected = [1, 1, 2, 3],
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
- matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
+ matchersUtil = new jasmineUnderTest.MatchersUtil({ pp: pp }),
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
- message = 'Expected $.length = |5| to equal |4|.\n' +
+ message =
+ 'Expected $.length = |5| to equal |4|.\n' +
'Unexpected $[4] = |5| in array.';
expect(matcher.compare(actual, expected).message).toEqual(message);
});
- it("expected array is longer", function() {
+ it('expected array is longer', function() {
var actual = [1, 1, 2, 3],
expected = [1, 1, 2, 3, 5],
- message = 'Expected $.length = 4 to equal 5.\n' +
+ message =
+ 'Expected $.length = 4 to equal 5.\n' +
'Expected $[4] = undefined to equal 5.';
expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("undefined in middle of actual array", function() {
+ it('undefined in middle of actual array', function() {
var actual = [1, void 0, 3],
expected = [1, 2, 3],
message = 'Expected $[1] = undefined to equal 2.';
@@ -951,7 +961,7 @@
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("undefined in middle of expected array", function() {
+ it('undefined in middle of expected array', function() {
var actual = [1, 2, 3],
expected = [1, void 0, 3],
message = 'Expected $[1] = 2 to equal undefined.';
@@ -960,10 +970,11 @@
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("actual array is longer by 4 elements", function() {
+ it('actual array is longer by 4 elements', function() {
var actual = [1, 1, 2, 3, 5, 8, 13],
expected = [1, 1, 2],
- message = 'Expected $.length = 7 to equal 3.\n' +
+ message =
+ 'Expected $.length = 7 to equal 3.\n' +
'Unexpected $[3] = 3 in array.\n' +
'Unexpected $[4] = 5 in array.\n' +
'Unexpected $[5] = 8 in array.\n' +
@@ -973,10 +984,11 @@
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("expected array is longer by 4 elements", function() {
+ it('expected array is longer by 4 elements', function() {
var actual = [1, 1, 2],
expected = [1, 1, 2, 3, 5, 8, 13],
- message = 'Expected $.length = 3 to equal 7.\n' +
+ message =
+ 'Expected $.length = 3 to equal 7.\n' +
'Expected $[3] = undefined to equal 3.\n' +
'Expected $[4] = undefined to equal 5.\n' +
'Expected $[5] = undefined to equal 8.\n' +
@@ -986,10 +998,11 @@
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("different length and different elements", function() {
+ it('different length and different elements', function() {
var actual = [1],
expected = [2, 3],
- message = 'Expected $.length = 1 to equal 2.\n' +
+ message =
+ 'Expected $.length = 1 to equal 2.\n' +
'Expected $[0] = 1 to equal 2.\n' +
'Expected $[1] = undefined to equal 3.';
@@ -997,50 +1010,55 @@
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("object with nested array (actual longer than expected)", function() {
+ it('object with nested array (actual longer than expected)', function() {
var actual = { values: [1, 1, 2, 3] },
expected = { values: [1, 1, 2] },
- message = 'Expected $.values.length = 4 to equal 3.\n' +
+ message =
+ 'Expected $.values.length = 4 to equal 3.\n' +
'Unexpected $.values[3] = 3 in array.';
expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("object with nested array (expected longer than actual)", function() {
+ it('object with nested array (expected longer than actual)', function() {
var actual = { values: [1, 1, 2] },
expected = { values: [1, 1, 2, 3] },
- message = 'Expected $.values.length = 3 to equal 4.\n' +
+ message =
+ 'Expected $.values.length = 3 to equal 4.\n' +
'Expected $.values[3] = undefined to equal 3.';
expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("array with unexpected nested object", function() {
+ it('array with unexpected nested object', function() {
var actual = [1, 1, 2, { value: 3 }],
expected = [1, 1, 2],
- message = 'Expected $.length = 4 to equal 3.\n' +
+ message =
+ 'Expected $.length = 4 to equal 3.\n' +
'Unexpected $[3] = Object({ value: 3 }) in array.';
expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("array with missing nested object", function() {
+ it('array with missing nested object', function() {
var actual = [1, 1, 2],
expected = [1, 1, 2, { value: 3 }],
- message = 'Expected $.length = 3 to equal 4.\n' +
+ message =
+ 'Expected $.length = 3 to equal 4.\n' +
'Expected $[3] = undefined to equal Object({ value: 3 }).';
expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("array with nested different length array", function() {
+ it('array with nested different length array', function() {
var actual = [[1], [1, 2]],
expected = [[1, 1], [2]],
- message = 'Expected $[0].length = 1 to equal 2.\n' +
+ message =
+ 'Expected $[0].length = 1 to equal 2.\n' +
'Expected $[0][1] = undefined to equal 1.\n' +
'Expected $[1].length = 2 to equal 1.\n' +
'Expected $[1][0] = 1 to equal 2.\n' +
@@ -1050,7 +1068,7 @@
expect(compareEquals(actual, expected).message).toEqual(message);
});
- it("last element of longer array is undefined", function() {
+ it('last element of longer array is undefined', function() {
var actual = [1, 2],
expected = [1, 2, void 0],
message = 'Expected $.length = 2 to equal 3.';
@@ -1058,5 +1076,5 @@
expect(compareEquals(actual, expected).pass).toBe(false);
expect(compareEquals(actual, expected).message).toEqual(message);
});
- })
+ });
});
diff --git a/spec/core/matchers/toHaveBeenCalledBeforeSpec.js b/spec/core/matchers/toHaveBeenCalledBeforeSpec.js
index 266758f..2bf316e 100644
--- a/spec/core/matchers/toHaveBeenCalledBeforeSpec.js
+++ b/spec/core/matchers/toHaveBeenCalledBeforeSpec.js
@@ -1,29 +1,29 @@
-describe("toHaveBeenCalledBefore", function() {
- it("throws an exception when the actual is not a spy", function() {
+describe('toHaveBeenCalledBefore', function() {
+ it('throws an exception when the actual is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore({
- pp: jasmineUnderTest.makePrettyPrinter()
- }),
- fn = function() {},
- spy = new jasmineUnderTest.Env().createSpy('a spy');
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ fn = function() {},
+ spy = new jasmineUnderTest.Env().createSpy('a spy');
- expect(function () {
+ expect(function() {
matcher.compare(fn, spy);
}).toThrowError(Error, /Expected a spy, but got Function./);
});
- it("throws an exception when the expected is not a spy", function() {
+ it('throws an exception when the expected is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore({
- pp: jasmineUnderTest.makePrettyPrinter()
- }),
- spy = new jasmineUnderTest.Env().createSpy('a spy'),
- fn = function() {};
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ spy = new jasmineUnderTest.Env().createSpy('a spy'),
+ fn = function() {};
- expect(function () {
+ expect(function() {
matcher.compare(spy, fn);
}).toThrowError(Error, /Expected a spy, but got Function./);
});
- it("fails when the actual was not called", function () {
+ it('fails when the actual was not called', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy');
@@ -32,10 +32,12 @@
result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(false);
- expect(result.message).toMatch(/Expected spy first spy to have been called./);
+ expect(result.message).toMatch(
+ /Expected spy first spy to have been called./
+ );
});
- it("fails when the expected was not called", function () {
+ it('fails when the expected was not called', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy');
@@ -44,10 +46,12 @@
result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(false);
- expect(result.message).toMatch(/Expected spy second spy to have been called./);
+ expect(result.message).toMatch(
+ /Expected spy second spy to have been called./
+ );
});
- it("fails when the actual is called after the expected", function () {
+ it('fails when the actual is called after the expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy'),
@@ -58,10 +62,12 @@
result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(false);
- expect(result.message).toEqual('Expected spy first spy to have been called before spy second spy');
+ expect(result.message).toEqual(
+ 'Expected spy first spy to have been called before spy second spy'
+ );
});
- it("fails when the actual is called before and after the expected", function () {
+ it('fails when the actual is called before and after the expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy'),
@@ -73,10 +79,12 @@
result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(false);
- expect(result.message).toEqual('Expected latest call to spy first spy to have been called before first call to spy second spy (no interleaved calls)');
+ expect(result.message).toEqual(
+ 'Expected latest call to spy first spy to have been called before first call to spy second spy (no interleaved calls)'
+ );
});
- it("fails when the expected is called before and after the actual", function () {
+ it('fails when the expected is called before and after the actual', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy'),
@@ -88,10 +96,12 @@
result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(false);
- expect(result.message).toEqual('Expected first call to spy second spy to have been called after latest call to spy first spy (no interleaved calls)');
+ expect(result.message).toEqual(
+ 'Expected first call to spy second spy to have been called after latest call to spy first spy (no interleaved calls)'
+ );
});
- it("passes when the actual is called before the expected", function () {
+ it('passes when the actual is called before the expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledBefore(),
firstSpy = new jasmineUnderTest.Spy('first spy'),
secondSpy = new jasmineUnderTest.Spy('second spy'),
@@ -102,6 +112,8 @@
result = matcher.compare(firstSpy, secondSpy);
expect(result.pass).toBe(true);
- expect(result.message).toEqual('Expected spy first spy to not have been called before spy second spy, but it was');
+ expect(result.message).toEqual(
+ 'Expected spy first spy to not have been called before spy second spy, but it was'
+ );
});
});
diff --git a/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js b/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js
index be0e95b..bb144cf 100644
--- a/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js
+++ b/spec/core/matchers/toHaveBeenCalledOnceWithSpec.js
@@ -1,6 +1,5 @@
-describe("toHaveBeenCalledOnceWith", function () {
-
- it("passes when the actual was called only once and with matching parameters", function () {
+describe('toHaveBeenCalledOnceWith', function() {
+ it('passes when the actual was called only once and with matching parameters', function() {
var util = jasmineUnderTest.matchersUtil,
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
@@ -10,13 +9,23 @@
result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(true);
- expect(result.message).toEqual("Expected spy called-spy to have been called 0 times, multiple times, or once, but with arguments different from:\n [ 'a', 'b' ]\nBut the actual call was:\n [ 'a', 'b' ].\n\n");
+ expect(result.message).toEqual(
+ "Expected spy called-spy to have been called 0 times, multiple times, or once, but with arguments different from:\n [ 'a', 'b' ]\nBut the actual call was:\n [ 'a', 'b' ].\n\n"
+ );
});
- it("supports custom equality testers", function () {
- var customEqualityTesters = [function() { return true; }],
- matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: customEqualityTesters}),
- matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(matchersUtil),
+ it('supports custom equality testers', function() {
+ var customEqualityTesters = [
+ function() {
+ return true;
+ }
+ ],
+ matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: customEqualityTesters
+ }),
+ matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(
+ matchersUtil
+ ),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
@@ -26,7 +35,7 @@
expect(result.pass).toBe(true);
});
- it("fails when the actual was never called", function () {
+ it('fails when the actual was never called', function() {
var util = jasmineUnderTest.matchersUtil,
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
@@ -35,10 +44,12 @@
result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(false);
- expect(result.message).toEqual("Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut it was never called.\n\n");
+ expect(result.message).toEqual(
+ "Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut it was never called.\n\n"
+ );
});
- it("fails when the actual was called once with different parameters", function () {
+ it('fails when the actual was called once with different parameters', function() {
var util = jasmineUnderTest.matchersUtil,
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
@@ -48,10 +59,12 @@
result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(false);
- expect(result.message).toEqual("Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut the actual call was:\n [ 'a', 'c' ].\nExpected $[1] = 'c' to equal 'b'.\n\n");
+ expect(result.message).toEqual(
+ "Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut the actual call was:\n [ 'a', 'c' ].\nExpected $[1] = 'c' to equal 'b'.\n\n"
+ );
});
- it("fails when the actual was called multiple times with expected parameters", function () {
+ it('fails when the actual was called multiple times with expected parameters', function() {
var util = jasmineUnderTest.matchersUtil,
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
@@ -62,10 +75,12 @@
result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(false);
- expect(result.message).toEqual("Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut the actual calls were:\n [ 'a', 'b' ],\n [ 'a', 'b' ].\n\n");
+ expect(result.message).toEqual(
+ "Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut the actual calls were:\n [ 'a', 'b' ],\n [ 'a', 'b' ].\n\n"
+ );
});
- it("fails when the actual was called multiple times (one of them - with expected parameters)", function () {
+ it('fails when the actual was called multiple times (one of them - with expected parameters)', function() {
var util = jasmineUnderTest.matchersUtil,
matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(util),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
@@ -76,13 +91,17 @@
result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(false);
- expect(result.message).toEqual("Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut the actual calls were:\n [ 'a', 'b' ],\n [ 'a', 'c' ].\n\n");
+ expect(result.message).toEqual(
+ "Expected spy called-spy to have been called only once, and with given args:\n [ 'a', 'b' ]\nBut the actual calls were:\n [ 'a', 'b' ],\n [ 'a', 'c' ].\n\n"
+ );
});
- it("throws an exception when the actual is not a spy", function () {
+ it('throws an exception when the actual is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledOnceWith(),
- fn = function () { };
+ fn = function() {};
- expect(function () { matcher.compare(fn) }).toThrowError(/Expected a spy, but got Function./);
+ expect(function() {
+ matcher.compare(fn);
+ }).toThrowError(/Expected a spy, but got Function./);
});
});
diff --git a/spec/core/matchers/toHaveBeenCalledSpec.js b/spec/core/matchers/toHaveBeenCalledSpec.js
index 65106cf..ebc9a9c 100644
--- a/spec/core/matchers/toHaveBeenCalledSpec.js
+++ b/spec/core/matchers/toHaveBeenCalledSpec.js
@@ -1,5 +1,5 @@
-describe("toHaveBeenCalled", function() {
- it("passes when the actual was called, with a custom .not fail message", function() {
+describe('toHaveBeenCalled', function() {
+ it('passes when the actual was called, with a custom .not fail message', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
@@ -8,10 +8,12 @@
result = matcher.compare(calledSpy);
expect(result.pass).toBe(true);
- expect(result.message).toEqual("Expected spy called-spy not to have been called.");
+ expect(result.message).toEqual(
+ 'Expected spy called-spy not to have been called.'
+ );
});
- it("fails when the actual was not called", function() {
+ it('fails when the actual was not called', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'),
result;
@@ -20,30 +22,35 @@
expect(result.pass).toBe(false);
});
- it("throws an exception when the actual is not a spy", function() {
+ it('throws an exception when the actual is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {};
- expect(function() { matcher.compare(fn) }).toThrowError(Error, /Expected a spy, but got Function./);
+ expect(function() {
+ matcher.compare(fn);
+ }).toThrowError(Error, /Expected a spy, but got Function./);
});
- it("throws an exception when invoked with any arguments", function() {
+ it('throws an exception when invoked with any arguments', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
spy = new jasmineUnderTest.Spy('sample spy');
- expect(function() { matcher.compare(spy, 'foo') }).toThrowError(Error, /Does not take arguments, use toHaveBeenCalledWith/);
+ expect(function() {
+ matcher.compare(spy, 'foo');
+ }).toThrowError(Error, /Does not take arguments, use toHaveBeenCalledWith/);
});
- it("has a custom message on failure", function() {
+ it('has a custom message on failure', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
spy = new jasmineUnderTest.Spy('sample-spy'),
result;
result = matcher.compare(spy);
- expect(result.message).toEqual("Expected spy sample-spy to have been called.");
+ expect(result.message).toEqual(
+ 'Expected spy sample-spy to have been called.'
+ );
});
});
-
diff --git a/spec/core/matchers/toHaveBeenCalledTimesSpec.js b/spec/core/matchers/toHaveBeenCalledTimesSpec.js
index e2c0c0e..12075ad 100644
--- a/spec/core/matchers/toHaveBeenCalledTimesSpec.js
+++ b/spec/core/matchers/toHaveBeenCalledTimesSpec.js
@@ -1,12 +1,12 @@
-describe("toHaveBeenCalledTimes", function() {
- it("passes when the actual 0 matches the expected 0 ", function () {
+describe('toHaveBeenCalledTimes', function() {
+ it('passes when the actual 0 matches the expected 0 ', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
- calledSpy = new jasmineUnderTest.Spy('called-spy'),
- result;
+ calledSpy = new jasmineUnderTest.Spy('called-spy'),
+ result;
result = matcher.compare(calledSpy, 0);
expect(result.pass).toBeTruthy();
});
- it("passes when the actual matches the expected", function() {
+ it('passes when the actual matches the expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
@@ -16,18 +16,20 @@
expect(result.pass).toBe(true);
});
- it("fails when expected numbers is not supplied", function(){
- var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
+ it('fails when expected numbers is not supplied', function() {
+ var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
spy = new jasmineUnderTest.Spy('spy'),
result;
spy();
- expect(function() {
- matcher.compare(spy);
- }).toThrowError(/The expected times failed is a required argument and must be a number./);
+ expect(function() {
+ matcher.compare(spy);
+ }).toThrowError(
+ /The expected times failed is a required argument and must be a number./
+ );
});
- it("fails when the actual was called less than the expected", function() {
+ it('fails when the actual was called less than the expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'),
result;
@@ -36,7 +38,7 @@
expect(result.pass).toBe(false);
});
- it("fails when the actual was called more than expected", function() {
+ it('fails when the actual was called more than expected', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'),
result;
@@ -48,7 +50,7 @@
expect(result.pass).toBe(false);
});
- it("throws an exception when the actual is not a spy", function() {
+ it('throws an exception when the actual is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -59,7 +61,7 @@
}).toThrowError(/Expected a spy, but got Function./);
});
- it("has a custom message on failure that tells it was called only once", function() {
+ it('has a custom message on failure that tells it was called only once', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
spy = new jasmineUnderTest.Spy('sample-spy'),
result;
@@ -69,10 +71,14 @@
spy();
result = matcher.compare(spy, 1);
- expect(result.message).toEqual('Expected spy sample-spy to have been called once. It was called ' + 4 + ' times.');
+ expect(result.message).toEqual(
+ 'Expected spy sample-spy to have been called once. It was called ' +
+ 4 +
+ ' times.'
+ );
});
- it("has a custom message on failure that tells how many times it was called", function() {
+ it('has a custom message on failure that tells how many times it was called', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
spy = new jasmineUnderTest.Spy('sample-spy'),
result;
@@ -82,7 +88,10 @@
spy();
result = matcher.compare(spy, 2);
- expect(result.message).toEqual('Expected spy sample-spy to have been called 2 times. It was called ' + 4 + ' times.');
+ expect(result.message).toEqual(
+ 'Expected spy sample-spy to have been called 2 times. It was called ' +
+ 4 +
+ ' times.'
+ );
});
});
-
diff --git a/spec/core/matchers/toHaveBeenCalledWithSpec.js b/spec/core/matchers/toHaveBeenCalledWithSpec.js
index 5f391d6..a0f869a 100644
--- a/spec/core/matchers/toHaveBeenCalledWithSpec.js
+++ b/spec/core/matchers/toHaveBeenCalledWithSpec.js
@@ -1,24 +1,31 @@
-describe("toHaveBeenCalledWith", function() {
-
- it("passes when the actual was called with matching parameters", function() {
+describe('toHaveBeenCalledWith', function() {
+ it('passes when the actual was called with matching parameters', function() {
var matchersUtil = {
- contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
- pp: jasmineUnderTest.makePrettyPrinter()
- },
- matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
- calledSpy = new jasmineUnderTest.Spy('called-spy'),
- result;
+ contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
+ pp: jasmineUnderTest.makePrettyPrinter()
+ },
+ matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
+ calledSpy = new jasmineUnderTest.Spy('called-spy'),
+ result;
calledSpy('a', 'b');
result = matcher.compare(calledSpy, 'a', 'b');
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected spy called-spy not to have been called with:\n [ 'a', 'b' ]\nbut it was.");
+ expect(result.message()).toEqual(
+ "Expected spy called-spy not to have been called with:\n [ 'a', 'b' ]\nbut it was."
+ );
});
- it("supports custom equality testers", function() {
- var customEqualityTesters = [function() { return true; }],
- matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: customEqualityTesters}),
+ it('supports custom equality testers', function() {
+ var customEqualityTesters = [
+ function() {
+ return true;
+ }
+ ],
+ matchersUtil = new jasmineUnderTest.MatchersUtil({
+ customTesters: customEqualityTesters
+ }),
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
calledSpy = new jasmineUnderTest.Spy('called-spy'),
result;
@@ -28,25 +35,31 @@
expect(result.pass).toBe(true);
});
- it("fails when the actual was not called", function() {
+ it('fails when the actual was not called', function() {
var matchersUtil = {
- contains: jasmine.createSpy('delegated-contains').and.returnValue(false),
- pp: jasmineUnderTest.makePrettyPrinter()
- },
- matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
- uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'),
- result;
+ contains: jasmine
+ .createSpy('delegated-contains')
+ .and.returnValue(false),
+ pp: jasmineUnderTest.makePrettyPrinter()
+ },
+ matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
+ uncalledSpy = new jasmineUnderTest.Spy('uncalled spy'),
+ result;
result = matcher.compare(uncalledSpy);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected spy uncalled spy to have been called with:\n [ ]\nbut it was never called.");
+ expect(result.message()).toEqual(
+ 'Expected spy uncalled spy to have been called with:\n [ ]\nbut it was never called.'
+ );
});
- it("fails when the actual was called with different parameters", function() {
- var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
- matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
- calledSpy = new jasmineUnderTest.Spy('called spy'),
- result;
+ it('fails when the actual was called with different parameters', function() {
+ var matchersUtil = new jasmineUnderTest.MatchersUtil({
+ pp: jasmineUnderTest.makePrettyPrinter()
+ }),
+ matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
+ calledSpy = new jasmineUnderTest.Spy('called spy'),
+ result;
calledSpy('a');
calledSpy('c', 'd');
@@ -55,30 +68,32 @@
expect(result.pass).toBe(false);
expect(result.message()).toEqual(
- "Expected spy called spy to have been called with:\n" +
- " [ 'a', 'b' ]\n" +
- "but actual calls were:\n" +
- " [ 'a' ],\n" +
- " [ 'c', 'd' ],\n" +
- " [ 'a', 'b', 'c' ].\n\n" +
- "Call 0:\n" +
- " Expected $.length = 1 to equal 2.\n" +
- " Expected $[1] = undefined to equal 'b'.\n" +
- "Call 1:\n" +
- " Expected $[0] = 'c' to equal 'a'.\n" +
- " Expected $[1] = 'd' to equal 'b'.\n" +
- "Call 2:\n" +
- " Expected $.length = 3 to equal 2.\n" +
- " Unexpected $[2] = 'c' in array.");
+ 'Expected spy called spy to have been called with:\n' +
+ " [ 'a', 'b' ]\n" +
+ 'but actual calls were:\n' +
+ " [ 'a' ],\n" +
+ " [ 'c', 'd' ],\n" +
+ " [ 'a', 'b', 'c' ].\n\n" +
+ 'Call 0:\n' +
+ ' Expected $.length = 1 to equal 2.\n' +
+ " Expected $[1] = undefined to equal 'b'.\n" +
+ 'Call 1:\n' +
+ " Expected $[0] = 'c' to equal 'a'.\n" +
+ " Expected $[1] = 'd' to equal 'b'.\n" +
+ 'Call 2:\n' +
+ ' Expected $.length = 3 to equal 2.\n' +
+ " Unexpected $[2] = 'c' in array."
+ );
});
- it("throws an exception when the actual is not a spy", function() {
+ it('throws an exception when the actual is not a spy', function() {
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith({
pp: jasmineUnderTest.makePrettyPrinter()
}),
- fn = function () {
- };
+ fn = function() {};
- expect(function() { matcher.compare(fn) }).toThrowError(/Expected a spy, but got Function./);
+ expect(function() {
+ matcher.compare(fn);
+ }).toThrowError(/Expected a spy, but got Function./);
});
});
diff --git a/spec/core/matchers/toHaveClassSpec.js b/spec/core/matchers/toHaveClassSpec.js
index 5f593ab..d56a0a1 100644
--- a/spec/core/matchers/toHaveClassSpec.js
+++ b/spec/core/matchers/toHaveClassSpec.js
@@ -5,7 +5,10 @@
it('fails for a DOM element that lacks the expected class', function() {
var matcher = jasmineUnderTest.matchers.toHaveClass(),
- result = matcher.compare(this.domHelpers.createElementWithClassName(''), 'foo');
+ result = matcher.compare(
+ this.domHelpers.createElementWithClassName(''),
+ 'foo'
+ );
expect(result.pass).toBe(false);
});
@@ -41,11 +44,11 @@
var textNode = this.domHelpers.document.createTextNode('');
expect(function() {
- matcher.compare(textNode, 'foo')
+ matcher.compare(textNode, 'foo');
}).toThrowError('HTMLNode is not a DOM element');
expect(function() {
- matcher.compare({classList: ''}, 'foo');
+ matcher.compare({ classList: '' }, 'foo');
}).toThrowError("Object({ classList: '' }) is not a DOM element");
});
});
diff --git a/spec/core/matchers/toHaveSizeSpec.js b/spec/core/matchers/toHaveSizeSpec.js
index d25e39e..fc5baf9 100644
--- a/spec/core/matchers/toHaveSizeSpec.js
+++ b/spec/core/matchers/toHaveSizeSpec.js
@@ -18,28 +18,28 @@
it('passes for an object with the proper number of keys', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
- result = matcher.compare({a: 1, b: 2}, 2);
+ result = matcher.compare({ a: 1, b: 2 }, 2);
expect(result.pass).toBe(true);
});
it('fails for an object with a different number of keys', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
- result = matcher.compare({a: 1, b: 2}, 1);
+ result = matcher.compare({ a: 1, b: 2 }, 1);
expect(result.pass).toBe(false);
});
it('passes for an object with an explicit `length` property that matches', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
- result = matcher.compare({a: 1, b: 2, length: 5}, 5);
+ result = matcher.compare({ a: 1, b: 2, length: 5 }, 5);
expect(result.pass).toBe(true);
});
it('fails for an object with an explicit `length` property that does not match', function() {
var matcher = jasmineUnderTest.matchers.toHaveSize(),
- result = matcher.compare({a: 1, b: 2, length: 5}, 1);
+ result = matcher.compare({ a: 1, b: 2, length: 5 }, 1);
expect(result.pass).toBe(false);
});
@@ -62,8 +62,8 @@
jasmine.getEnv().requireFunctioningMaps();
var map = new Map();
- map.set('a',1);
- map.set('b',2);
+ map.set('a', 1);
+ map.set('b', 2);
var matcher = jasmineUnderTest.matchers.toHaveSize(),
result = matcher.compare(map, 2);
@@ -75,8 +75,8 @@
jasmine.getEnv().requireFunctioningMaps();
var map = new Map();
- map.set('a',1);
- map.set('b',2);
+ map.set('a', 1);
+ map.set('b', 2);
var matcher = jasmineUnderTest.matchers.toHaveSize(),
result = matcher.compare(map, 1);
diff --git a/spec/core/matchers/toMatchSpec.js b/spec/core/matchers/toMatchSpec.js
index b245e34..aa4d6c5 100644
--- a/spec/core/matchers/toMatchSpec.js
+++ b/spec/core/matchers/toMatchSpec.js
@@ -1,6 +1,5 @@
-describe("toMatch", function() {
-
- it("passes when RegExps are equivalent", function() {
+describe('toMatch', function() {
+ it('passes when RegExps are equivalent', function() {
var matcher = jasmineUnderTest.matchers.toMatch(),
result;
@@ -8,7 +7,7 @@
expect(result.pass).toBe(true);
});
- it("fails when RegExps are not equivalent", function() {
+ it('fails when RegExps are not equivalent', function() {
var matcher = jasmineUnderTest.matchers.toMatch(),
result;
@@ -16,7 +15,7 @@
expect(result.pass).toBe(false);
});
- it("passes when the actual matches the expected string as a pattern", function() {
+ it('passes when the actual matches the expected string as a pattern', function() {
var matcher = jasmineUnderTest.matchers.toMatch(),
result;
@@ -24,7 +23,7 @@
expect(result.pass).toBe(true);
});
- it("fails when the actual matches the expected string as a pattern", function() {
+ it('fails when the actual matches the expected string as a pattern', function() {
var matcher = jasmineUnderTest.matchers.toMatch(),
result;
@@ -32,7 +31,7 @@
expect(result.pass).toBe(false);
});
- it("throws an Error when the expected is not a String or RegExp", function() {
+ it('throws an Error when the expected is not a String or RegExp', function() {
var matcher = jasmineUnderTest.matchers.toMatch();
expect(function() {
@@ -40,4 +39,3 @@
}).toThrowError(/Expected is not a String or a RegExp/);
});
});
-
diff --git a/spec/core/matchers/toThrowErrorSpec.js b/spec/core/matchers/toThrowErrorSpec.js
index 68fdf8b..c853227 100644
--- a/spec/core/matchers/toThrowErrorSpec.js
+++ b/spec/core/matchers/toThrowErrorSpec.js
@@ -1,5 +1,5 @@
-describe("toThrowError", function() {
- it("throws an error when the actual is not a function", function() {
+describe('toThrowError', function() {
+ it('throws an error when the actual is not a function', function() {
var matcher = jasmineUnderTest.matchers.toThrowError();
expect(function() {
@@ -7,10 +7,10 @@
}).toThrowError(/Actual is not a Function/);
});
- it("throws an error when the expected is not an Error, string, or RegExp", function() {
+ it('throws an error when the expected is not an Error, string, or RegExp', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
- throw new Error("foo");
+ throw new Error('foo');
};
expect(function() {
@@ -18,21 +18,21 @@
}).toThrowError(/Expected is not an Error, string, or RegExp./);
});
- it("throws an error when the expected error type is not an Error", function() {
+ it('throws an error when the expected error type is not an Error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
- throw new Error("foo");
+ throw new Error('foo');
};
expect(function() {
- matcher.compare(fn, void 0, "foo");
+ matcher.compare(fn, void 0, 'foo');
}).toThrowError(/Expected error type is not an Error./);
});
- it("throws an error when the expected error message is not a string or RegExp", function() {
+ it('throws an error when the expected error message is not a string or RegExp', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
- throw new Error("foo");
+ throw new Error('foo');
};
expect(function() {
@@ -40,7 +40,7 @@
}).toThrowError(/Expected error message is not a string or RegExp./);
});
- it("fails if actual does not throw at all", function() {
+ it('fails if actual does not throw at all', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
return true;
@@ -50,10 +50,10 @@
result = matcher.compare(fn);
expect(result.pass).toBe(false);
- expect(result.message).toEqual("Expected function to throw an Error.");
+ expect(result.message).toEqual('Expected function to throw an Error.');
});
- it("fails if thrown is not an instanceof Error", function() {
+ it('fails if thrown is not an instanceof Error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -64,12 +64,14 @@
result = matcher.compare(fn);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw an Error, but it threw 4.");
+ expect(result.message()).toEqual(
+ 'Expected function to throw an Error, but it threw 4.'
+ );
});
- describe("when error is from another frame", function() {
+ describe('when error is from another frame', function() {
function isNotRunningInBrowser() {
- return typeof document === 'undefined'
+ return typeof document === 'undefined';
}
var iframe = null;
@@ -80,31 +82,36 @@
}
});
- it("passes if thrown is an instanceof Error regardless of global that contains its constructor", function() {
+ it('passes if thrown is an instanceof Error regardless of global that contains its constructor', function() {
if (isNotRunningInBrowser()) {
return;
}
var matcher = jasmineUnderTest.matchers.toThrowError();
- iframe = document.body.appendChild(document.createElement("iframe"));
- iframe.src = "about:blank";
+ iframe = document.body.appendChild(document.createElement('iframe'));
+ iframe.src = 'about:blank';
var iframeDocument = iframe.contentWindow.document;
if (iframeDocument.body) {
- iframeDocument.body.appendChild(iframeDocument.createElement("script"))
- .textContent = "function method() { throw new Error('foo'); }";
+ iframeDocument.body.appendChild(
+ iframeDocument.createElement('script')
+ ).textContent = "function method() { throw new Error('foo'); }";
} else {
// IE 10 and older
- iframeDocument.write("<html><head><script>function method() { throw new Error('foo'); }</script></head></html>");
+ iframeDocument.write(
+ "<html><head><script>function method() { throw new Error('foo'); }</script></head></html>"
+ );
}
var result = matcher.compare(iframe.contentWindow.method);
expect(result.pass).toBe(true);
- expect(result.message).toEqual("Expected function not to throw an Error, but it threw Error.");
+ expect(result.message).toEqual(
+ 'Expected function not to throw an Error, but it threw Error.'
+ );
});
});
- it("fails with the correct message if thrown is a falsy value", function() {
+ it('fails with the correct message if thrown is a falsy value', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -115,10 +122,12 @@
result = matcher.compare(fn);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw an Error, but it threw undefined.");
+ expect(result.message()).toEqual(
+ 'Expected function to throw an Error, but it threw undefined.'
+ );
});
- it("passes if thrown is a type of Error, but there is no expected error", function() {
+ it('passes if thrown is a type of Error, but there is no expected error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
throw new TypeError();
@@ -128,70 +137,80 @@
result = matcher.compare(fn);
expect(result.pass).toBe(true);
- expect(result.message).toEqual("Expected function not to throw an Error, but it threw TypeError.");
+ expect(result.message).toEqual(
+ 'Expected function not to throw an Error, but it threw TypeError.'
+ );
});
- it("passes if thrown is an Error and the expected is the same message", function() {
+ it('passes if thrown is an Error and the expected is the same message', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
- throw new Error("foo");
+ throw new Error('foo');
},
result;
- result = matcher.compare(fn, "foo");
+ result = matcher.compare(fn, 'foo');
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw an exception with message 'foo'.");
+ expect(result.message()).toEqual(
+ "Expected function not to throw an exception with message 'foo'."
+ );
});
- it("fails if thrown is an Error and the expected is not the same message", function() {
+ it('fails if thrown is an Error and the expected is not the same message', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
- throw new Error("foo");
+ throw new Error('foo');
},
result;
- result = matcher.compare(fn, "bar");
+ result = matcher.compare(fn, 'bar');
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw an exception with message 'bar', but it threw an exception with message 'foo'.");
+ expect(result.message()).toEqual(
+ "Expected function to throw an exception with message 'bar', but it threw an exception with message 'foo'."
+ );
});
- it("passes if thrown is an Error and the expected is a RegExp that matches the message", function() {
+ it('passes if thrown is an Error and the expected is a RegExp that matches the message', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
- throw new Error("a long message");
+ throw new Error('a long message');
},
result;
result = matcher.compare(fn, /long/);
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw an exception with a message matching /long/.");
+ expect(result.message()).toEqual(
+ 'Expected function not to throw an exception with a message matching /long/.'
+ );
});
- it("fails if thrown is an Error and the expected is a RegExp that does not match the message", function() {
+ it('fails if thrown is an Error and the expected is a RegExp that does not match the message', function() {
var matcher = jasmineUnderTest.matchers.toThrowError({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
- throw new Error("a long message");
+ throw new Error('a long message');
},
result;
result = matcher.compare(fn, /foo/);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw an exception with a message matching /foo/, but it threw an exception with message 'a long message'.");
+ expect(result.message()).toEqual(
+ "Expected function to throw an exception with a message matching /foo/, but it threw an exception with message 'a long message'."
+ );
});
- it("passes if thrown is an Error and the expected the same Error", function() {
+ it('passes if thrown is an Error and the expected the same Error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error();
@@ -201,12 +220,14 @@
result = matcher.compare(fn, Error);
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw Error.");
+ expect(result.message()).toEqual('Expected function not to throw Error.');
});
- it("passes if thrown is a custom error that takes arguments and the expected is the same error", function() {
+ it('passes if thrown is a custom error that takes arguments and the expected is the same error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
- CustomError = function CustomError(arg) { arg.x },
+ CustomError = function CustomError(arg) {
+ arg.x;
+ },
fn = function() {
throw new CustomError({ x: 1 });
},
@@ -217,10 +238,12 @@
result = matcher.compare(fn, CustomError);
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw CustomError.");
+ expect(result.message()).toEqual(
+ 'Expected function not to throw CustomError.'
+ );
});
- it("fails if thrown is an Error and the expected is a different Error", function() {
+ it('fails if thrown is an Error and the expected is a different Error', function() {
var matcher = jasmineUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error();
@@ -230,94 +253,108 @@
result = matcher.compare(fn, TypeError);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw TypeError, but it threw Error.");
+ expect(result.message()).toEqual(
+ 'Expected function to throw TypeError, but it threw Error.'
+ );
});
- it("passes if thrown is a type of Error and it is equal to the expected Error and message", function() {
+ it('passes if thrown is a type of Error and it is equal to the expected Error and message', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
- throw new TypeError("foo");
+ throw new TypeError('foo');
},
result;
- result = matcher.compare(fn, TypeError, "foo");
+ result = matcher.compare(fn, TypeError, 'foo');
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw TypeError with message 'foo'.");
+ expect(result.message()).toEqual(
+ "Expected function not to throw TypeError with message 'foo'."
+ );
});
- it("passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message", function() {
+ it('passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
- CustomError = function CustomError(arg) { this.message = arg.message; },
+ CustomError = function CustomError(arg) {
+ this.message = arg.message;
+ },
fn = function() {
- throw new CustomError({message: "foo"});
+ throw new CustomError({ message: 'foo' });
},
result;
CustomError.prototype = new Error();
- result = matcher.compare(fn, CustomError, "foo");
+ result = matcher.compare(fn, CustomError, 'foo');
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw CustomError with message 'foo'.");
+ expect(result.message()).toEqual(
+ "Expected function not to throw CustomError with message 'foo'."
+ );
});
- it("fails if thrown is a type of Error and the expected is a different Error", function() {
+ it('fails if thrown is a type of Error and the expected is a different Error', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
- throw new TypeError("foo");
+ throw new TypeError('foo');
},
result;
- result = matcher.compare(fn, TypeError, "bar");
+ result = matcher.compare(fn, TypeError, 'bar');
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw TypeError with message 'bar', but it threw TypeError with message 'foo'.");
+ expect(result.message()).toEqual(
+ "Expected function to throw TypeError with message 'bar', but it threw TypeError with message 'foo'."
+ );
});
- it("passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message", function() {
+ it('passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
- throw new TypeError("foo");
+ throw new TypeError('foo');
},
result;
result = matcher.compare(fn, TypeError, /foo/);
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw TypeError with a message matching /foo/.");
+ expect(result.message()).toEqual(
+ 'Expected function not to throw TypeError with a message matching /foo/.'
+ );
});
- it("fails if thrown is a type of Error and the expected is a different Error", function() {
+ it('fails if thrown is a type of Error and the expected is a different Error', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
- throw new TypeError("foo");
+ throw new TypeError('foo');
},
result;
result = matcher.compare(fn, TypeError, /bar/);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw TypeError with a message matching /bar/, but it threw TypeError with message 'foo'.");
+ expect(result.message()).toEqual(
+ "Expected function to throw TypeError with a message matching /bar/, but it threw TypeError with message 'foo'."
+ );
});
});
diff --git a/spec/core/matchers/toThrowMatchingSpec.js b/spec/core/matchers/toThrowMatchingSpec.js
index 507683b..a5ed2c5 100644
--- a/spec/core/matchers/toThrowMatchingSpec.js
+++ b/spec/core/matchers/toThrowMatchingSpec.js
@@ -1,16 +1,18 @@
-describe("toThrowMatching", function() {
- it("throws an error when the actual is not a function", function() {
+describe('toThrowMatching', function() {
+ it('throws an error when the actual is not a function', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching();
expect(function() {
- matcher.compare({}, function() { return true; });
+ matcher.compare({}, function() {
+ return true;
+ });
}).toThrowError(/Actual is not a Function/);
});
- it("throws an error when the expected is not a function", function() {
+ it('throws an error when the expected is not a function', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching(),
fn = function() {
- throw new Error("foo");
+ throw new Error('foo');
};
expect(function() {
@@ -18,20 +20,22 @@
}).toThrowError(/Predicate is not a Function/);
});
- it("fails if actual does not throw at all", function() {
+ it('fails if actual does not throw at all', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching(),
fn = function() {
return true;
},
result;
- result = matcher.compare(fn, function() { return true; });
+ result = matcher.compare(fn, function() {
+ return true;
+ });
expect(result.pass).toBe(false);
- expect(result.message).toEqual("Expected function to throw an exception.");
+ expect(result.message).toEqual('Expected function to throw an exception.');
});
- it("fails with the correct message if thrown is a falsy value", function() {
+ it('fails with the correct message if thrown is a falsy value', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -40,38 +44,50 @@
},
result;
- result = matcher.compare(fn, function() { return false; });
+ result = matcher.compare(fn, function() {
+ return false;
+ });
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw an exception matching a predicate, but it threw undefined.");
+ expect(result.message()).toEqual(
+ 'Expected function to throw an exception matching a predicate, but it threw undefined.'
+ );
});
- it("passes if the argument is a function that returns true when called with the error", function() {
+ it('passes if the argument is a function that returns true when called with the error', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching(),
- predicate = function(e) { return e.message === "nope" },
+ predicate = function(e) {
+ return e.message === 'nope';
+ },
fn = function() {
- throw new TypeError("nope");
+ throw new TypeError('nope');
},
result;
result = matcher.compare(fn, predicate);
expect(result.pass).toBe(true);
- expect(result.message).toEqual("Expected function not to throw an exception matching a predicate.");
+ expect(result.message).toEqual(
+ 'Expected function not to throw an exception matching a predicate.'
+ );
});
- it("fails if the argument is a function that returns false when called with the error", function() {
+ it('fails if the argument is a function that returns false when called with the error', function() {
var matcher = jasmineUnderTest.matchers.toThrowMatching({
pp: jasmineUnderTest.makePrettyPrinter()
}),
- predicate = function(e) { return e.message === "oh no" },
+ predicate = function(e) {
+ return e.message === 'oh no';
+ },
fn = function() {
- throw new TypeError("nope");
+ throw new TypeError('nope');
},
result;
result = matcher.compare(fn, predicate);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw an exception matching a predicate, but it threw TypeError with message 'nope'.");
+ expect(result.message()).toEqual(
+ "Expected function to throw an exception matching a predicate, but it threw TypeError with message 'nope'."
+ );
});
});
diff --git a/spec/core/matchers/toThrowSpec.js b/spec/core/matchers/toThrowSpec.js
index 7144b2b..0ed049d 100644
--- a/spec/core/matchers/toThrowSpec.js
+++ b/spec/core/matchers/toThrowSpec.js
@@ -1,6 +1,5 @@
-describe("toThrow", function() {
-
- it("throws an error when the actual is not a function", function() {
+describe('toThrow', function() {
+ it('throws an error when the actual is not a function', function() {
var matcher = jasmineUnderTest.matchers.toThrow();
expect(function() {
@@ -9,7 +8,7 @@
}).toThrowError(/Actual is not a Function/);
});
- it("fails if actual does not throw", function() {
+ it('fails if actual does not throw', function() {
var matcher = jasmineUnderTest.matchers.toThrow(),
fn = function() {
return true;
@@ -19,10 +18,10 @@
result = matcher.compare(fn);
expect(result.pass).toBe(false);
- expect(result.message).toEqual("Expected function to throw an exception.");
+ expect(result.message).toEqual('Expected function to throw an exception.');
});
- it("passes if it throws but there is no expected", function() {
+ it('passes if it throws but there is no expected', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
@@ -36,10 +35,12 @@
result = matcher.compare(fn);
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw, but it threw 5.");
+ expect(result.message()).toEqual(
+ 'Expected function not to throw, but it threw 5.'
+ );
});
- it("passes even if what is thrown is falsy", function() {
+ it('passes even if what is thrown is falsy', function() {
var matcher = jasmineUnderTest.matchers.toThrow({
pp: jasmineUnderTest.makePrettyPrinter()
}),
@@ -50,10 +51,12 @@
result = matcher.compare(fn);
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw, but it threw undefined.");
+ expect(result.message()).toEqual(
+ 'Expected function not to throw, but it threw undefined.'
+ );
});
- it("passes if what is thrown is equivalent to what is expected", function() {
+ it('passes if what is thrown is equivalent to what is expected', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
@@ -67,10 +70,10 @@
result = matcher.compare(fn, 5);
expect(result.pass).toBe(true);
- expect(result.message()).toEqual("Expected function not to throw 5.");
+ expect(result.message()).toEqual('Expected function not to throw 5.');
});
- it("fails if what is thrown is not equivalent to what is expected", function() {
+ it('fails if what is thrown is not equivalent to what is expected', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
@@ -81,13 +84,15 @@
},
result;
- result = matcher.compare(fn, "foo");
+ result = matcher.compare(fn, 'foo');
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw 'foo', but it threw 5.");
+ expect(result.message()).toEqual(
+ "Expected function to throw 'foo', but it threw 5."
+ );
});
- it("fails if what is thrown is not equivalent to undefined", function() {
+ it('fails if what is thrown is not equivalent to undefined', function() {
var matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
@@ -101,6 +106,8 @@
result = matcher.compare(fn, void 0);
expect(result.pass).toBe(false);
- expect(result.message()).toEqual("Expected function to throw undefined, but it threw 5.");
+ expect(result.message()).toEqual(
+ 'Expected function to throw undefined, but it threw 5.'
+ );
});
});
diff --git a/src/core/asymmetric_equality/Any.js b/src/core/asymmetric_equality/Any.js
index 61273de..bbee1bd 100644
--- a/src/core/asymmetric_equality/Any.js
+++ b/src/core/asymmetric_equality/Any.js
@@ -1,10 +1,9 @@
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;
diff --git a/src/core/asymmetric_equality/Anything.js b/src/core/asymmetric_equality/Anything.js
index 11c6571..ce436cb 100644
--- a/src/core/asymmetric_equality/Anything.js
+++ b/src/core/asymmetric_equality/Anything.js
@@ -1,5 +1,4 @@
getJasmineRequireObj().Anything = function(j$) {
-
function Anything() {}
Anything.prototype.asymmetricMatch = function(other) {
diff --git a/src/core/asymmetric_equality/ArrayContaining.js b/src/core/asymmetric_equality/ArrayContaining.js
index 7faea8b..c00a2dc 100644
--- a/src/core/asymmetric_equality/ArrayContaining.js
+++ b/src/core/asymmetric_equality/ArrayContaining.js
@@ -5,7 +5,11 @@
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
@@ -25,8 +29,8 @@
return true;
};
- ArrayContaining.prototype.jasmineToString = function (pp) {
- return '<jasmine.arrayContaining(' + pp(this.sample) +')>';
+ ArrayContaining.prototype.jasmineToString = function(pp) {
+ return '<jasmine.arrayContaining(' + pp(this.sample) + ')>';
};
return ArrayContaining;
diff --git a/src/core/asymmetric_equality/ArrayWithExactContents.js b/src/core/asymmetric_equality/ArrayWithExactContents.js
index d204904..f207dc7 100644
--- a/src/core/asymmetric_equality/ArrayWithExactContents.js
+++ b/src/core/asymmetric_equality/ArrayWithExactContents.js
@@ -1,12 +1,18 @@
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) {
diff --git a/src/core/asymmetric_equality/Empty.js b/src/core/asymmetric_equality/Empty.js
index 224c0f5..1dd2894 100644
--- a/src/core/asymmetric_equality/Empty.js
+++ b/src/core/asymmetric_equality/Empty.js
@@ -1,8 +1,7 @@
-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;
}
@@ -17,7 +16,7 @@
return false;
};
- Empty.prototype.jasmineToString = function () {
+ Empty.prototype.jasmineToString = function() {
return '<jasmine.empty>';
};
diff --git a/src/core/asymmetric_equality/Falsy.js b/src/core/asymmetric_equality/Falsy.js
index 242e0af..d1d3c8f 100644
--- a/src/core/asymmetric_equality/Falsy.js
+++ b/src/core/asymmetric_equality/Falsy.js
@@ -1,5 +1,4 @@
getJasmineRequireObj().Falsy = function(j$) {
-
function Falsy() {}
Falsy.prototype.asymmetricMatch = function(other) {
diff --git a/src/core/asymmetric_equality/MapContaining.js b/src/core/asymmetric_equality/MapContaining.js
index ba6b0ce..0270d1b 100644
--- a/src/core/asymmetric_equality/MapContaining.js
+++ b/src/core/asymmetric_equality/MapContaining.js
@@ -1,7 +1,9 @@
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;
@@ -17,8 +19,8 @@
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();
diff --git a/src/core/asymmetric_equality/NotEmpty.js b/src/core/asymmetric_equality/NotEmpty.js
index 3c0368c..361b697 100644
--- a/src/core/asymmetric_equality/NotEmpty.js
+++ b/src/core/asymmetric_equality/NotEmpty.js
@@ -1,8 +1,7 @@
-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;
}
@@ -18,7 +17,7 @@
return false;
};
- NotEmpty.prototype.jasmineToString = function () {
+ NotEmpty.prototype.jasmineToString = function() {
return '<jasmine.notEmpty>';
};
diff --git a/src/core/asymmetric_equality/ObjectContaining.js b/src/core/asymmetric_equality/ObjectContaining.js
index 4a8f438..5e47303 100644
--- a/src/core/asymmetric_equality/ObjectContaining.js
+++ b/src/core/asymmetric_equality/ObjectContaining.js
@@ -1,5 +1,4 @@
getJasmineRequireObj().ObjectContaining = function(j$) {
-
function ObjectContaining(sample) {
this.sample = sample;
}
@@ -17,7 +16,7 @@
}
function hasProperty(obj, property) {
- if (!obj || typeof(obj) !== 'object') {
+ if (!obj || typeof obj !== 'object') {
return false;
}
@@ -29,12 +28,22 @@
}
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;
}
}
@@ -51,7 +60,7 @@
}
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];
diff --git a/src/core/asymmetric_equality/SetContaining.js b/src/core/asymmetric_equality/SetContaining.js
index f3ad352..5682808 100644
--- a/src/core/asymmetric_equality/SetContaining.js
+++ b/src/core/asymmetric_equality/SetContaining.js
@@ -1,7 +1,9 @@
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;
diff --git a/src/core/asymmetric_equality/StringMatching.js b/src/core/asymmetric_equality/StringMatching.js
index 7233472..ebcc173 100644
--- a/src/core/asymmetric_equality/StringMatching.js
+++ b/src/core/asymmetric_equality/StringMatching.js
@@ -1,5 +1,4 @@
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');
diff --git a/src/core/asymmetric_equality/Truthy.js b/src/core/asymmetric_equality/Truthy.js
index a852fda..9e52716 100644
--- a/src/core/asymmetric_equality/Truthy.js
+++ b/src/core/asymmetric_equality/Truthy.js
@@ -1,5 +1,4 @@
getJasmineRequireObj().Truthy = function(j$) {
-
function Truthy() {}
Truthy.prototype.asymmetricMatch = function(other) {
diff --git a/src/core/matchers/DiffBuilder.js b/src/core/matchers/DiffBuilder.js
index 70b52ea..c8c0e49 100644
--- a/src/core/matchers/DiffBuilder.js
+++ b/src/core/matchers/DiffBuilder.js
@@ -1,4 +1,4 @@
-getJasmineRequireObj().DiffBuilder = function (j$) {
+getJasmineRequireObj().DiffBuilder = function(j$) {
return function DiffBuilder(config) {
var prettyPrinter = (config || {}).prettyPrinter || j$.makePrettyPrinter(),
mismatches = new j$.MismatchTree(),
@@ -7,21 +7,28 @@
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;
@@ -32,15 +39,22 @@
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;
@@ -49,7 +63,7 @@
return messages.join('\n');
},
- withPath: function (pathComponent, block) {
+ withPath: function(pathComponent, block) {
var oldPath = path;
path = path.add(pathComponent);
block();
@@ -58,22 +72,32 @@
};
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;
@@ -89,7 +113,6 @@
handleAsymmetricExpected();
}
- return {actual: actual, expected: expected};
+ return { actual: actual, expected: expected };
}
-
};
diff --git a/src/core/matchers/MismatchTree.js b/src/core/matchers/MismatchTree.js
index 1ce356d..3fdab88 100644
--- a/src/core/matchers/MismatchTree.js
+++ b/src/core/matchers/MismatchTree.js
@@ -1,5 +1,4 @@
-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
@@ -14,7 +13,7 @@
this.isMismatch = false;
}
- MismatchTree.prototype.add = function (path, formatter) {
+ MismatchTree.prototype.add = function(path, formatter) {
var key, child;
if (path.depth() === 0) {
@@ -34,8 +33,9 @@
}
};
- 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)) {
@@ -59,4 +59,3 @@
return MismatchTree;
};
-
diff --git a/src/core/matchers/ObjectPath.js b/src/core/matchers/ObjectPath.js
index a9acfdb..2ffc884 100644
--- a/src/core/matchers/ObjectPath.js
+++ b/src/core/matchers/ObjectPath.js
@@ -32,7 +32,7 @@
return '.' + prop;
}
- return '[\'' + prop + '\']';
+ return "['" + prop + "']";
}
function map(array, fn) {
diff --git a/src/core/matchers/async/toBePending.js b/src/core/matchers/async/toBePending.js
index 758eb99..8ef12a2 100644
--- a/src/core/matchers/async/toBePending.js
+++ b/src/core/matchers/async/toBePending.js
@@ -17,8 +17,12 @@
}
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 };
+ }
);
}
};
diff --git a/src/core/matchers/async/toBeRejected.js b/src/core/matchers/async/toBeRejected.js
index 3ec95bf..d75fa34 100644
--- a/src/core/matchers/async/toBeRejected.js
+++ b/src/core/matchers/async/toBeRejected.js
@@ -17,8 +17,12 @@
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 };
+ }
);
}
};
diff --git a/src/core/matchers/async/toBeRejectedWith.js b/src/core/matchers/async/toBeRejectedWith.js
index 6c0af90..7436dbc 100644
--- a/src/core/matchers/async/toBeRejectedWith.js
+++ b/src/core/matchers/async/toBeRejectedWith.js
@@ -15,35 +15,44 @@
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) +
+ '.'
+ };
+ }
}
- }
);
}
};
diff --git a/src/core/matchers/async/toBeRejectedWithError.js b/src/core/matchers/async/toBeRejectedWithError.js
index 203cd86..5b2aed5 100644
--- a/src/core/matchers/async/toBeRejectedWithError.js
+++ b/src/core/matchers/async/toBeRejectedWithError.js
@@ -18,7 +18,9 @@
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);
@@ -30,7 +32,9 @@
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);
+ }
);
}
};
@@ -42,16 +46,25 @@
}
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);
}
@@ -61,18 +74,25 @@
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;
@@ -87,11 +107,16 @@
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))
+ );
}
};
diff --git a/src/core/matchers/async/toBeResolved.js b/src/core/matchers/async/toBeResolved.js
index 997ddee..b9dda27 100644
--- a/src/core/matchers/async/toBeResolved.js
+++ b/src/core/matchers/async/toBeResolved.js
@@ -18,8 +18,12 @@
}
return actual.then(
- function() { return {pass: true}; },
- function() { return {pass: false}; }
+ function() {
+ return { pass: true };
+ },
+ function() {
+ return { pass: false };
+ }
);
}
};
diff --git a/src/core/matchers/async/toBeResolvedTo.js b/src/core/matchers/async/toBeResolvedTo.js
index 61abb9f..f95e7b1 100644
--- a/src/core/matchers/async/toBeResolvedTo.js
+++ b/src/core/matchers/async/toBeResolvedTo.js
@@ -19,9 +19,12 @@
}
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(
@@ -34,7 +37,11 @@
} 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) +
+ '.'
};
}
},
diff --git a/src/core/matchers/matchersUtil.js b/src/core/matchers/matchersUtil.js
index d473976..6a74d89 100644
--- a/src/core/matchers/matchersUtil.js
+++ b/src/core/matchers/matchersUtil.js
@@ -21,7 +21,7 @@
* @return {string} The pretty-printed value
*/
this.pp = options.pp || function() {};
- };
+ }
/**
* Determines whether `haystack` contains `needle`, using the same comparison
@@ -39,9 +39,10 @@
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 @@
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 @@
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 @@
* @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 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
}
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 @@
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 @@
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 @@
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 @@
};
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 @@
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 @@
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) {
diff --git a/src/core/matchers/toBe.js b/src/core/matchers/toBe.js
index 8115adc..81177c2 100644
--- a/src/core/matchers/toBe.js
+++ b/src/core/matchers/toBe.js
@@ -9,7 +9,8 @@
* 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) {
@@ -18,7 +19,13 @@
};
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;
diff --git a/src/core/matchers/toBeCloseTo.js b/src/core/matchers/toBeCloseTo.js
index 6cd0a01..b539214 100644
--- a/src/core/matchers/toBeCloseTo.js
+++ b/src/core/matchers/toBeCloseTo.js
@@ -17,8 +17,13 @@
}
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 +
+ ').'
);
}
diff --git a/src/core/matchers/toBeDefined.js b/src/core/matchers/toBeDefined.js
index ae95091..0c43f7d 100644
--- a/src/core/matchers/toBeDefined.js
+++ b/src/core/matchers/toBeDefined.js
@@ -11,7 +11,7 @@
return {
compare: function(actual) {
return {
- pass: (void 0 !== actual)
+ pass: void 0 !== actual
};
}
};
diff --git a/src/core/matchers/toBeGreaterThan.js b/src/core/matchers/toBeGreaterThan.js
index ffe7ad6..07dad33 100644
--- a/src/core/matchers/toBeGreaterThan.js
+++ b/src/core/matchers/toBeGreaterThan.js
@@ -20,4 +20,3 @@
return toBeGreaterThan;
};
-
diff --git a/src/core/matchers/toBeInstanceOf.js b/src/core/matchers/toBeInstanceOf.js
index 609b930..2241402 100644
--- a/src/core/matchers/toBeInstanceOf.js
+++ b/src/core/matchers/toBeInstanceOf.js
@@ -1,5 +1,8 @@
getJasmineRequireObj().toBeInstanceOf = function(j$) {
- var usageError = j$.formatErrorMsg('<toBeInstanceOf>', 'expect(value).toBeInstanceOf(<ConstructorFunction>)');
+ var usageError = j$.formatErrorMsg(
+ '<toBeInstanceOf>',
+ 'expect(value).toBeInstanceOf(<ConstructorFunction>)'
+ );
/**
* {@link expect} the actual to be an instance of the expected class
@@ -15,27 +18,42 @@
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
};
}
}
diff --git a/src/core/matchers/toBeLessThan.js b/src/core/matchers/toBeLessThan.js
index 319113a..162e52f 100644
--- a/src/core/matchers/toBeLessThan.js
+++ b/src/core/matchers/toBeLessThan.js
@@ -10,7 +10,6 @@
*/
function toBeLessThan() {
return {
-
compare: function(actual, expected) {
return {
pass: actual < expected
diff --git a/src/core/matchers/toBeLessThanOrEqual.js b/src/core/matchers/toBeLessThanOrEqual.js
index 4820fc9..f2d47b6 100644
--- a/src/core/matchers/toBeLessThanOrEqual.js
+++ b/src/core/matchers/toBeLessThanOrEqual.js
@@ -10,7 +10,6 @@
*/
function toBeLessThanOrEqual() {
return {
-
compare: function(actual, expected) {
return {
pass: actual <= expected
diff --git a/src/core/matchers/toBeNaN.js b/src/core/matchers/toBeNaN.js
index 7adf5b3..b26ef5f 100644
--- a/src/core/matchers/toBeNaN.js
+++ b/src/core/matchers/toBeNaN.js
@@ -11,13 +11,15 @@
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;
diff --git a/src/core/matchers/toBeNegativeInfinity.js b/src/core/matchers/toBeNegativeInfinity.js
index fe2de80..2518a9c 100644
--- a/src/core/matchers/toBeNegativeInfinity.js
+++ b/src/core/matchers/toBeNegativeInfinity.js
@@ -11,13 +11,15 @@
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;
diff --git a/src/core/matchers/toBePositiveInfinity.js b/src/core/matchers/toBePositiveInfinity.js
index 39cb5e3..17523c9 100644
--- a/src/core/matchers/toBePositiveInfinity.js
+++ b/src/core/matchers/toBePositiveInfinity.js
@@ -11,13 +11,15 @@
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;
diff --git a/src/core/matchers/toContain.js b/src/core/matchers/toContain.js
index 5732447..9ab3015 100644
--- a/src/core/matchers/toContain.js
+++ b/src/core/matchers/toContain.js
@@ -12,7 +12,6 @@
function toContain(matchersUtil) {
return {
compare: function(actual, expected) {
-
return {
pass: matchersUtil.contains(actual, expected)
};
diff --git a/src/core/matchers/toEqual.js b/src/core/matchers/toEqual.js
index 3a7add3..d2db1bd 100644
--- a/src/core/matchers/toEqual.js
+++ b/src/core/matchers/toEqual.js
@@ -14,7 +14,7 @@
var result = {
pass: false
},
- diffBuilder = j$.DiffBuilder({prettyPrinter: matchersUtil.pp});
+ diffBuilder = j$.DiffBuilder({ prettyPrinter: matchersUtil.pp });
result.pass = matchersUtil.equals(actual, expected, diffBuilder);
diff --git a/src/core/matchers/toHaveBeenCalled.js b/src/core/matchers/toHaveBeenCalled.js
index 3e6d260..ef1ea60 100644
--- a/src/core/matchers/toHaveBeenCalled.js
+++ b/src/core/matchers/toHaveBeenCalled.js
@@ -1,6 +1,8 @@
getJasmineRequireObj().toHaveBeenCalled = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalled>', 'expect(<spyObj>).toHaveBeenCalled()');
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toHaveBeenCalled>',
+ 'expect(<spyObj>).toHaveBeenCalled()'
+ );
/**
* {@link expect} the actual (a {@link Spy}) to have been called.
@@ -17,18 +19,24 @@
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;
}
diff --git a/src/core/matchers/toHaveBeenCalledBefore.js b/src/core/matchers/toHaveBeenCalledBefore.js
index 293e73f..ad1de7c 100644
--- a/src/core/matchers/toHaveBeenCalledBefore.js
+++ b/src/core/matchers/toHaveBeenCalledBefore.js
@@ -1,6 +1,8 @@
getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalledBefore>', 'expect(<spyObj>).toHaveBeenCalledBefore(<spyObj>)');
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toHaveBeenCalledBefore>',
+ 'expect(<spyObj>).toHaveBeenCalledBefore(<spyObj>)'
+ );
/**
* {@link expect} the actual value (a {@link Spy}) to have been called before another {@link Spy}.
@@ -15,20 +17,30 @@
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;
}
@@ -38,17 +50,36 @@
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;
}
}
diff --git a/src/core/matchers/toHaveBeenCalledOnceWith.js b/src/core/matchers/toHaveBeenCalledOnceWith.js
index d7be378..fc26b53 100644
--- a/src/core/matchers/toHaveBeenCalledOnceWith.js
+++ b/src/core/matchers/toHaveBeenCalledOnceWith.js
@@ -1,6 +1,8 @@
-getJasmineRequireObj().toHaveBeenCalledOnceWith = function (j$) {
-
- var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalledOnceWith>', 'expect(<spyObj>).toHaveBeenCalledOnceWith(...arguments)');
+getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) {
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toHaveBeenCalledOnceWith>',
+ 'expect(<spyObj>).toHaveBeenCalledOnceWith(...arguments)'
+ );
/**
* {@link expect} the actual (a {@link Spy}) to have been called exactly once, and exactly with the particular arguments.
@@ -13,31 +15,44 @@
*/
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 ' + j$.pp(actual) + '.'));
+ throw new Error(
+ getErrorMsg('Expected a spy, but got ' + j$.pp(actual) + '.')
+ );
}
- var prettyPrintedCalls = actual.calls.allArgs().map(function (argsForCall) {
- return ' ' + j$.pp(argsForCall);
- });
+ var prettyPrintedCalls = actual.calls
+ .allArgs()
+ .map(function(argsForCall) {
+ return ' ' + j$.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'
- + ' ' + j$.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' +
+ ' ' +
+ j$.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();
@@ -49,17 +64,32 @@
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'
- + ' ' + j$.pp(expectedArgs) + '\n'
- + butString()
+ message:
+ 'Expected spy ' +
+ actual.and.identity +
+ ' to have been called only once, and with given args:\n' +
+ ' ' +
+ j$.pp(expectedArgs) +
+ '\n' +
+ butString()
};
}
};
diff --git a/src/core/matchers/toHaveBeenCalledTimes.js b/src/core/matchers/toHaveBeenCalledTimes.js
index fa3eef3..f3bcac3 100644
--- a/src/core/matchers/toHaveBeenCalledTimes.js
+++ b/src/core/matchers/toHaveBeenCalledTimes.js
@@ -1,6 +1,8 @@
getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalledTimes>', 'expect(<spyObj>).toHaveBeenCalledTimes(<Number>)');
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toHaveBeenCalledTimes>',
+ 'expect(<spyObj>).toHaveBeenCalledTimes(<Number>)'
+ );
/**
* {@link expect} the actual (a {@link Spy}) to have been called the specified number of times.
@@ -15,23 +17,43 @@
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;
}
};
diff --git a/src/core/matchers/toHaveBeenCalledWith.js b/src/core/matchers/toHaveBeenCalledWith.js
index 76628b5..0a646b8 100644
--- a/src/core/matchers/toHaveBeenCalledWith.js
+++ b/src/core/matchers/toHaveBeenCalledWith.js
@@ -1,6 +1,8 @@
getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalledWith>', 'expect(<spyObj>).toHaveBeenCalledWith(...arguments)');
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toHaveBeenCalledWith>',
+ 'expect(<spyObj>).toHaveBeenCalledWith(...arguments)'
+ );
/**
* {@link expect} the actual (a {@link Spy}) to have been called with particular arguments at least once.
@@ -20,14 +22,23 @@
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;
}
@@ -35,28 +46,49 @@
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')
+ );
};
}
diff --git a/src/core/matchers/toHaveClass.js b/src/core/matchers/toHaveClass.js
index efe17f1..218e729 100644
--- a/src/core/matchers/toHaveClass.js
+++ b/src/core/matchers/toHaveClass.js
@@ -25,9 +25,9 @@
}
function isElement(maybeEl) {
- return maybeEl &&
- maybeEl.classList &&
- j$.isFunction_(maybeEl.classList.contains);
+ return (
+ maybeEl && maybeEl.classList && j$.isFunction_(maybeEl.classList.contains)
+ );
}
return toHaveClass;
diff --git a/src/core/matchers/toHaveSize.js b/src/core/matchers/toHaveSize.js
index 03c8d43..403080a 100644
--- a/src/core/matchers/toHaveSize.js
+++ b/src/core/matchers/toHaveSize.js
@@ -13,10 +13,14 @@
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 + '.');
}
@@ -33,9 +37,14 @@
};
}
- 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;
diff --git a/src/core/matchers/toMatch.js b/src/core/matchers/toMatch.js
index 7d8f658..bb3ca3a 100644
--- a/src/core/matchers/toMatch.js
+++ b/src/core/matchers/toMatch.js
@@ -1,6 +1,8 @@
getJasmineRequireObj().toMatch = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('<toMatch>', 'expect(<expectation>).toMatch(<string> || <regexp>)');
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toMatch>',
+ 'expect(<expectation>).toMatch(<string> || <regexp>)'
+ );
/**
* {@link expect} the actual value to match a regular expression
diff --git a/src/core/matchers/toThrow.js b/src/core/matchers/toThrow.js
index a471a5d..b1db2b4 100644
--- a/src/core/matchers/toThrow.js
+++ b/src/core/matchers/toThrow.js
@@ -1,6 +1,8 @@
getJasmineRequireObj().toThrow = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('<toThrow>', 'expect(function() {<expectation>}).toThrow()');
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toThrow>',
+ 'expect(function() {<expectation>}).toThrow()'
+ );
/**
* {@link expect} a function to `throw` something.
@@ -37,16 +39,36 @@
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;
diff --git a/src/core/matchers/toThrowError.js b/src/core/matchers/toThrowError.js
index 00f3e69..3851360 100644
--- a/src/core/matchers/toThrowError.js
+++ b/src/core/matchers/toThrowError.js
@@ -1,6 +1,8 @@
getJasmineRequireObj().toThrowError = function(j$) {
-
- var getErrorMsg = j$.formatErrorMsg('<toThrowError>', 'expect(function() {<expectation>}).toThrowError(<ErrorConstructor>, <message>)');
+ var getErrorMsg = j$.formatErrorMsg(
+ '<toThrowError>',
+ 'expect(function() {<expectation>}).toThrowError(<ErrorConstructor>, <message>)'
+ );
/**
* {@link expect} a function to `throw` an `Error`.
@@ -34,7 +36,13 @@
}
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);
@@ -68,7 +76,11 @@
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) +
+ '.'
+ );
}
};
}
@@ -76,9 +88,13 @@
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.')
+ );
}
}
@@ -90,11 +106,15 @@
}
}
- 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);
@@ -114,20 +134,33 @@
}
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) +
+ '.'
+ );
});
}
}
@@ -135,7 +168,7 @@
}
function isStringOrRegExp(potential) {
- return potential instanceof RegExp || (typeof potential == 'string');
+ return potential instanceof RegExp || typeof potential == 'string';
}
function isAnErrorType(type) {
diff --git a/src/core/matchers/toThrowMatching.js b/src/core/matchers/toThrowMatching.js
index 45e3fc8..e594b1f 100644
--- a/src/core/matchers/toThrowMatching.js
+++ b/src/core/matchers/toThrowMatching.js
@@ -1,5 +1,8 @@
getJasmineRequireObj().toThrowMatching = function(j$) {
- var usageError = j$.formatErrorMsg('<toThrowMatching>', 'expect(function() {<expectation>}).toThrowMatching(<Predicate>)');
+ var usageError = j$.formatErrorMsg(
+ '<toThrowMatching>',
+ 'expect(function() {<expectation>}).toThrowMatching(<Predicate>)'
+ );
/**
* {@link expect} a function to `throw` something matching a predicate.
@@ -31,20 +34,29 @@
}
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);
}