summaryrefslogtreecommitdiff
path: root/test/parallel/test-async-wrap-constructor.js
blob: 6b1764337128b9ed6874386b416cca3e01d03213 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'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,
    });
  }
}