Files
node/test/parallel/test-http2-server-settimeout-no-callback.js
Phillip Markert 86c871eced test: replace forEach() with for...of in parallel tests
Replace `Array.prototype.forEach()` with `for...of` loops across 17
tests in `test/parallel`, so each loop body reads as a plain statement
rather than an arrow callback.

None of the iterated values are sparse arrays, the one case where
`forEach` and `for...of` genuinely differ, so both constructs visit the
same elements in the same order. No callback relied on `this`, an early
return, or async behaviour, and the number of assertions run in each
file is unchanged.

Signed-off-by: Phillip Markert <phillip@ephisys.com>
PR-URL: https://github.com/nodejs/node/pull/65272
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
2026-08-15 21:59:44 +00:00

41 lines
928 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const http2 = require('http2');
// Verify that setTimeout callback verifications work correctly
const verifyCallbacks = common.mustCall((server) => {
const testTimeout = 10;
const testCases = [true, 1, {}, [], null, 'test'];
for (const notFunction of testCases) {
assert.throws(
() => server.setTimeout(testTimeout, notFunction),
{
name: 'TypeError',
code: 'ERR_INVALID_ARG_TYPE',
}
);
};
// No callback
const returnedVal = server.setTimeout(testTimeout);
assert.strictEqual(returnedVal.timeout, testTimeout);
}, 2);
// Test with server
{
const server = http2.createServer();
verifyCallbacks(server);
}
// Test with secure server
{
const secureServer = http2.createSecureServer({});
verifyCallbacks(secureServer);
}