We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c82c084 commit 11ea13fCopy full SHA for 11ea13f
1 file changed
test/parallel/test-async-hooks-constructor.js
@@ -5,20 +5,17 @@
5
require('../common');
6
const assert = require('assert');
7
const async_hooks = require('async_hooks');
8
-const non_function = 10;
+const nonFunctionArray = [null, -1, 1, {}, []];
9
10
-typeErrorForFunction('init');
11
-typeErrorForFunction('before');
12
-typeErrorForFunction('after');
13
-typeErrorForFunction('destroy');
14
-typeErrorForFunction('promiseResolve');
15
-
16
-function typeErrorForFunction(functionName) {
17
- assert.throws(() => {
18
- async_hooks.createHook({ [functionName]: non_function });
19
- }, {
20
- code: 'ERR_ASYNC_CALLBACK',
21
- name: 'TypeError',
22
- message: `hook.${functionName} must be a function`
+['init', 'before', 'after', 'destroy', 'promiseResolve'].forEach(
+ (functionName) => {
+ nonFunctionArray.forEach((nonFunction) => {
+ assert.throws(() => {
+ async_hooks.createHook({ [functionName]: nonFunction });
+ }, {
+ code: 'ERR_ASYNC_CALLBACK',
+ name: 'TypeError',
+ message: `hook.${functionName} must be a function`,
+ });
23
});
24
-}
0 commit comments