0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/test/parallel/test-async-wrap-constructor.js
Mithun Sasidharan 146a9b1a8a
test: replace assert.throws w/ common.expectsError
PR-URL: https://github.com/nodejs/node/pull/17483
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-12-08 16:23:32 -05:00

19 lines
502 B
JavaScript

'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,
});
}
}