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:
Steve Gravrock
2017-10-28 10:05:28 -07:00
committed by Steve Gravrock
parent 908583c49b
commit 9f7a6ef061
2 changed files with 14 additions and 14 deletions

View File

@@ -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)) {

View File

@@ -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)) {