blob: 62ec854108e9dcb993cba53668fd2144a5c0acbe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
'use strict';
// This tests that AsyncHooks throws an error if bad parameters are passed.
require('../common');
const assert = require('assert');
const async_hooks = require('async_hooks');
const nonFunctionArray = [null, -1, 1, {}, []];
['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`,
});
});
});
|