mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
test: replace forEach() with for .. of
PR-URL: https://github.com/nodejs/node/pull/50605 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
@@ -6,15 +6,16 @@ require('../common');
|
||||
const assert = require('assert');
|
||||
const async_hooks = require('async_hooks');
|
||||
|
||||
[0, 1, false, true, null, 'hello'].forEach((badArg) => {
|
||||
const falsyValues = [0, 1, false, true, null, 'hello'];
|
||||
for (const badArg of falsyValues) {
|
||||
const hookNames = ['init', 'before', 'after', 'destroy', 'promiseResolve'];
|
||||
hookNames.forEach((field) => {
|
||||
for (const hookName of hookNames) {
|
||||
assert.throws(() => {
|
||||
async_hooks.createHook({ [field]: badArg });
|
||||
async_hooks.createHook({ [hookName]: badArg });
|
||||
}, {
|
||||
code: 'ERR_ASYNC_CALLBACK',
|
||||
name: 'TypeError',
|
||||
message: `hook.${field} must be a function`
|
||||
message: `hook.${hookName} must be a function`
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user