mirror of
https://github.com/nodejs/node.git
synced 2024-11-29 23:16:30 +01:00
146a9b1a8a
PR-URL: https://github.com/nodejs/node/pull/17483 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
19 lines
502 B
JavaScript
19 lines
502 B
JavaScript
'use strict';
|
|
|
|
// This tests that using falsy values in createHook throws an error.
|
|
|
|
const common = require('../common');
|
|
const async_hooks = require('async_hooks');
|
|
|
|
for (const badArg of [0, 1, false, true, null, 'hello']) {
|
|
const hookNames = ['init', 'before', 'after', 'destroy', 'promiseResolve'];
|
|
for (const field of hookNames) {
|
|
common.expectsError(() => {
|
|
async_hooks.createHook({ [field]: badArg });
|
|
}, {
|
|
code: 'ERR_ASYNC_CALLBACK',
|
|
type: TypeError,
|
|
});
|
|
}
|
|
}
|