Skip to content

Commit 11ea13f

Browse files
himself65BethGriggs
authored andcommitted
test: refactor test-async-hooks-constructor
PR-URL: #33063 Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent c82c084 commit 11ea13f

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

‎test/parallel/test-async-hooks-constructor.js‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@
55
require('../common');
66
constassert=require('assert');
77
constasync_hooks=require('async_hooks');
8-
constnon_function=10;
8+
constnonFunctionArray=[null,-1,1,{},[]];
99

10-
typeErrorForFunction('init');
11-
typeErrorForFunction('before');
12-
typeErrorForFunction('after');
13-
typeErrorForFunction('destroy');
14-
typeErrorForFunction('promiseResolve');
15-
16-
functiontypeErrorForFunction(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`
10+
['init','before','after','destroy','promiseResolve'].forEach(
11+
(functionName)=>{
12+
nonFunctionArray.forEach((nonFunction)=>{
13+
assert.throws(()=>{
14+
async_hooks.createHook({[functionName]: nonFunction});
15+
},{
16+
code: 'ERR_ASYNC_CALLBACK',
17+
name: 'TypeError',
18+
message: `hook.${functionName} must be a function`,
19+
});
20+
});
2321
});
24-
}

0 commit comments

Comments
(0)