assert: fix incorrect use of ERR_INVALID_ARG_TYPE
PR-URL: https://github.com/nodejs/node/pull/14011 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
8b2c61c169
commit
1d7414354e
@ -527,7 +527,7 @@ function innerThrows(shouldThrow, block, expected, message) {
|
||||
if (typeof block !== 'function') {
|
||||
const errors = lazyErrors();
|
||||
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'block', 'function',
|
||||
typeof block);
|
||||
block);
|
||||
}
|
||||
|
||||
if (typeof expected === 'string') {
|
||||
|
@ -669,10 +669,9 @@ try {
|
||||
|
||||
{
|
||||
// Verify that throws() and doesNotThrow() throw on non-function block
|
||||
const validationFunction = common.expectsError({
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
type: TypeError
|
||||
});
|
||||
function typeName(value) {
|
||||
return value === null ? 'null' : typeof value;
|
||||
}
|
||||
|
||||
const testBlockTypeError = (method, block) => {
|
||||
let threw = true;
|
||||
@ -681,7 +680,12 @@ try {
|
||||
method(block);
|
||||
threw = false;
|
||||
} catch (e) {
|
||||
validationFunction(e);
|
||||
common.expectsError({
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
type: TypeError,
|
||||
message: 'The "block" argument must be of type function. Received ' +
|
||||
'type ' + typeName(block)
|
||||
})(e);
|
||||
}
|
||||
|
||||
assert.ok(threw);
|
||||
|
Loading…
x
Reference in New Issue
Block a user