unexpected
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -256,13 +256,25 @@ /*global namespace*/ | ||
var errorMethodBlacklist = reduce(['message', 'line', 'sourceId', 'sourceURL', 'stack', 'stackArray'], function (result, prop) { | ||
result[prop] = true; | ||
return result; | ||
}, {}); | ||
function errorWithMessage(e, message) { | ||
var newError = new Error(message); | ||
forEach(getKeys(e), function (key) { | ||
if (!errorMethodBlacklist[key]) { | ||
newError[key] = e[key]; | ||
} | ||
}); | ||
return newError; | ||
} | ||
function handleNestedExpects(e, assertion) { | ||
switch (assertion.errorMode) { | ||
case 'nested': | ||
e.message = assertion.standardErrorMessage() + '\n ' + e.message.replace(/\n/g, '\n '); | ||
break; | ||
return errorWithMessage(e, assertion.standardErrorMessage() + '\n ' + e.message.replace(/\n/g, '\n ')); | ||
case 'default': | ||
e.message = assertion.standardErrorMessage(); | ||
break; | ||
return errorWithMessage(e, assertion.standardErrorMessage()); | ||
case 'bubble': | ||
break; | ||
return e; | ||
default: | ||
@@ -322,3 +334,3 @@ throw new Error("Unknown error mode: '" + assertion.errorMode + "'"); | ||
if (nestingLevel === 0) { | ||
handleNestedExpects(e, assertion); | ||
throw handleNestedExpects(e, assertion); | ||
} | ||
@@ -325,0 +337,0 @@ } |
{ | ||
"name": "unexpected", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"author": "Sune Sloth Simonsen <sune@we-knowhow.dk>", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -489,13 +489,25 @@ (function () { | ||
var errorMethodBlacklist = reduce(['message', 'line', 'sourceId', 'sourceURL', 'stack', 'stackArray'], function (result, prop) { | ||
result[prop] = true; | ||
return result; | ||
}, {}); | ||
function errorWithMessage(e, message) { | ||
var newError = new Error(message); | ||
forEach(getKeys(e), function (key) { | ||
if (!errorMethodBlacklist[key]) { | ||
newError[key] = e[key]; | ||
} | ||
}); | ||
return newError; | ||
} | ||
function handleNestedExpects(e, assertion) { | ||
switch (assertion.errorMode) { | ||
case 'nested': | ||
e.message = assertion.standardErrorMessage() + '\n ' + e.message.replace(/\n/g, '\n '); | ||
break; | ||
return errorWithMessage(e, assertion.standardErrorMessage() + '\n ' + e.message.replace(/\n/g, '\n ')); | ||
case 'default': | ||
e.message = assertion.standardErrorMessage(); | ||
break; | ||
return errorWithMessage(e, assertion.standardErrorMessage()); | ||
case 'bubble': | ||
break; | ||
return e; | ||
default: | ||
@@ -555,3 +567,3 @@ throw new Error("Unknown error mode: '" + assertion.errorMode + "'"); | ||
if (nestingLevel === 0) { | ||
handleNestedExpects(e, assertion); | ||
throw handleNestedExpects(e, assertion); | ||
} | ||
@@ -558,0 +570,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
322238
6534