Check truthiness of toThrowError args, not arg count
This enables some useful simplifications at the cost of making it impossible (for now) to expect a function to throw an error with a falsy message. [#20622765]
This commit is contained in:
committed by
Steve Gravrock
parent
908583c49b
commit
9f7a6ef061
@@ -3755,18 +3755,18 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
var expected = null,
|
||||
errorType = null;
|
||||
|
||||
if (arguments.length == 2) {
|
||||
expected = arguments[1];
|
||||
if (isAnErrorType(expected)) {
|
||||
errorType = expected;
|
||||
expected = null;
|
||||
}
|
||||
} else if (arguments.length > 2) {
|
||||
if (arguments[2]) {
|
||||
errorType = arguments[1];
|
||||
expected = arguments[2];
|
||||
if (!isAnErrorType(errorType)) {
|
||||
throw new Error(getErrorMsg('Expected error type is not an Error.'));
|
||||
}
|
||||
} else if (arguments[1]) {
|
||||
expected = arguments[1];
|
||||
if (isAnErrorType(expected)) {
|
||||
errorType = expected;
|
||||
expected = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (expected && !isStringOrRegExp(expected)) {
|
||||
|
||||
@@ -71,18 +71,18 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
var expected = null,
|
||||
errorType = null;
|
||||
|
||||
if (arguments.length == 2) {
|
||||
expected = arguments[1];
|
||||
if (isAnErrorType(expected)) {
|
||||
errorType = expected;
|
||||
expected = null;
|
||||
}
|
||||
} else if (arguments.length > 2) {
|
||||
if (arguments[2]) {
|
||||
errorType = arguments[1];
|
||||
expected = arguments[2];
|
||||
if (!isAnErrorType(errorType)) {
|
||||
throw new Error(getErrorMsg('Expected error type is not an Error.'));
|
||||
}
|
||||
} else if (arguments[1]) {
|
||||
expected = arguments[1];
|
||||
if (isAnErrorType(expected)) {
|
||||
errorType = expected;
|
||||
expected = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (expected && !isStringOrRegExp(expected)) {
|
||||
|
||||
Reference in New Issue
Block a user