0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

test: simplify common.expectsError

The mustCall is actually only necessary in case it is used as
callback. Otherwise it works as a must call on its own.

PR-URL: https://github.com/nodejs/node/pull/17616
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
This commit is contained in:
Ruben Bridgewater 2017-12-11 06:34:57 -02:00
parent e17dba7a45
commit 8d5b3de8cb
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -735,7 +735,7 @@ exports.expectsError = function expectsError(fn, settings, exact) {
settings = fn;
fn = undefined;
}
const innerFn = exports.mustCall(function(error) {
function innerFn(error) {
assert.strictEqual(error.code, settings.code);
if ('type' in settings) {
const type = settings.type;
@ -768,12 +768,12 @@ exports.expectsError = function expectsError(fn, settings, exact) {
});
}
return true;
}, exact);
}
if (fn) {
assert.throws(fn, innerFn);
return;
}
return innerFn;
return exports.mustCall(innerFn, exact);
};
exports.skipIfInspectorDisabled = function skipIfInspectorDisabled() {