0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-async-wrap-constructor.js
Evgenia Blajer b8cfb35745
test: replace forEach() with for .. of
PR-URL: https://github.com/nodejs/node/pull/50605
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2023-11-11 15:19:42 +00:00

22 lines
609 B
JavaScript

'use strict';
// This tests that using falsy values in createHook throws an error.
require('../common');
const assert = require('assert');
const async_hooks = require('async_hooks');
const falsyValues = [0, 1, false, true, null, 'hello'];
for (const badArg of falsyValues) {
const hookNames = ['init', 'before', 'after', 'destroy', 'promiseResolve'];
for (const hookName of hookNames) {
assert.throws(() => {
async_hooks.createHook({ [hookName]: badArg });
}, {
code: 'ERR_ASYNC_CALLBACK',
name: 'TypeError',
message: `hook.${hookName} must be a function`
});
}
}