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:
parent
e17dba7a45
commit
8d5b3de8cb
@ -735,7 +735,7 @@ exports.expectsError = function expectsError(fn, settings, exact) {
|
|||||||
settings = fn;
|
settings = fn;
|
||||||
fn = undefined;
|
fn = undefined;
|
||||||
}
|
}
|
||||||
const innerFn = exports.mustCall(function(error) {
|
function innerFn(error) {
|
||||||
assert.strictEqual(error.code, settings.code);
|
assert.strictEqual(error.code, settings.code);
|
||||||
if ('type' in settings) {
|
if ('type' in settings) {
|
||||||
const type = settings.type;
|
const type = settings.type;
|
||||||
@ -768,12 +768,12 @@ exports.expectsError = function expectsError(fn, settings, exact) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}, exact);
|
}
|
||||||
if (fn) {
|
if (fn) {
|
||||||
assert.throws(fn, innerFn);
|
assert.throws(fn, innerFn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return innerFn;
|
return exports.mustCall(innerFn, exact);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.skipIfInspectorDisabled = function skipIfInspectorDisabled() {
|
exports.skipIfInspectorDisabled = function skipIfInspectorDisabled() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user