Run Prettier on all files
This commit is contained in:
@@ -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 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
}
|
||||
|
||||
if (!j$.isError_(thrown)) {
|
||||
return fail(function() { return 'Expected function to throw an Error, but it threw ' + matchersUtil.pp(thrown) + '.'; });
|
||||
return fail(function() {
|
||||
return (
|
||||
'Expected function to throw an Error, but it threw ' +
|
||||
matchersUtil.pp(thrown) +
|
||||
'.'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return errorMatcher.match(thrown);
|
||||
@@ -68,7 +76,11 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
function anyMatcher() {
|
||||
return {
|
||||
match: function(error) {
|
||||
return pass('Expected function not to throw an Error, but it threw ' + j$.fnNameFor(error) + '.');
|
||||
return pass(
|
||||
'Expected function not to throw an Error, but it threw ' +
|
||||
j$.fnNameFor(error) +
|
||||
'.'
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -76,9 +88,13 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
function exactMatcher(expected, errorType) {
|
||||
if (expected && !isStringOrRegExp(expected)) {
|
||||
if (errorType) {
|
||||
throw new Error(getErrorMsg('Expected error message is not a string or RegExp.'));
|
||||
throw new Error(
|
||||
getErrorMsg('Expected error message is not a string or RegExp.')
|
||||
);
|
||||
} else {
|
||||
throw new Error(getErrorMsg('Expected is not an Error, string, or RegExp.'));
|
||||
throw new Error(
|
||||
getErrorMsg('Expected is not an Error, string, or RegExp.')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,11 +106,15 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
}
|
||||
}
|
||||
|
||||
var errorTypeDescription = errorType ? j$.fnNameFor(errorType) : 'an exception';
|
||||
var errorTypeDescription = errorType
|
||||
? j$.fnNameFor(errorType)
|
||||
: 'an exception';
|
||||
|
||||
function thrownDescription(thrown) {
|
||||
var thrownName = errorType ? j$.fnNameFor(thrown.constructor) : 'an exception',
|
||||
thrownMessage = '';
|
||||
var thrownName = errorType
|
||||
? j$.fnNameFor(thrown.constructor)
|
||||
: 'an exception',
|
||||
thrownMessage = '';
|
||||
|
||||
if (expected) {
|
||||
thrownMessage = ' with message ' + matchersUtil.pp(thrown.message);
|
||||
@@ -114,20 +134,33 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
}
|
||||
|
||||
function matches(error) {
|
||||
return (errorType === null || error instanceof errorType) &&
|
||||
(expected === null || messageMatch(error.message));
|
||||
return (
|
||||
(errorType === null || error instanceof errorType) &&
|
||||
(expected === null || messageMatch(error.message))
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
match: function(thrown) {
|
||||
if (matches(thrown)) {
|
||||
return pass(function() {
|
||||
return 'Expected function not to throw ' + errorTypeDescription + messageDescription() + '.';
|
||||
return (
|
||||
'Expected function not to throw ' +
|
||||
errorTypeDescription +
|
||||
messageDescription() +
|
||||
'.'
|
||||
);
|
||||
});
|
||||
} else {
|
||||
return fail(function() {
|
||||
return 'Expected function to throw ' + errorTypeDescription + messageDescription() +
|
||||
', but it threw ' + thrownDescription(thrown) + '.';
|
||||
return (
|
||||
'Expected function to throw ' +
|
||||
errorTypeDescription +
|
||||
messageDescription() +
|
||||
', but it threw ' +
|
||||
thrownDescription(thrown) +
|
||||
'.'
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -135,7 +168,7 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
}
|
||||
|
||||
function isStringOrRegExp(potential) {
|
||||
return potential instanceof RegExp || (typeof potential == 'string');
|
||||
return potential instanceof RegExp || typeof potential == 'string';
|
||||
}
|
||||
|
||||
function isAnErrorType(type) {
|
||||
|
||||
Reference in New Issue
Block a user