mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 17:01:08 +00:00

Fixes a line of uncovered code in the AsyncWrap class's constructor. Specifically this covers validtion of the 'promiseResolve' argument. PR-URL: https://github.com/nodejs/node/pull/16025 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
20 lines
551 B
JavaScript
20 lines
551 B
JavaScript
'use strict';
|
|
|
|
// This tests that using falsy values in createHook throws an error.
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
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) {
|
|
assert.throws(() => {
|
|
async_hooks.createHook({ [field]: badArg });
|
|
}, common.expectsError({
|
|
code: 'ERR_ASYNC_CALLBACK',
|
|
type: TypeError,
|
|
}));
|
|
}
|
|
}
|