test: test-async-wrap-constructor prefer forEach

PR-URL: https://github.com/nodejs/node/pull/32631
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Daniel Estiven Rico Posada 2020-04-02 21:54:56 -05:00 committed by Juan José Arboleda
parent 3140fdcd34
commit e99ec39610

View File

@ -6,14 +6,15 @@ require('../common');
const assert = require('assert');
const async_hooks = require('async_hooks');
for (const badArg of [0, 1, false, true, null, 'hello']) {
[0, 1, false, true, null, 'hello'].forEach((badArg) => {
const hookNames = ['init', 'before', 'after', 'destroy', 'promiseResolve'];
for (const field of hookNames) {
hookNames.forEach((field) => {
assert.throws(() => {
async_hooks.createHook({ [field]: badArg });
}, {
code: 'ERR_ASYNC_CALLBACK',
name: 'TypeError',
message: `hook.${field} must be a function`
});
}
}
});
});