test: replace forEach() in test-stream-pipe-unpipe-stream

PR-URL: https://github.com/nodejs/node/pull/50786
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Dario 2024-05-12 12:28:20 +02:00 committed by GitHub
parent 56b316294d
commit 06cde5c902
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -45,13 +45,12 @@ assert.strictEqual(source._readableState.pipes.length, 0);
const checkSrcCleanup = common.mustCall(() => {
assert.strictEqual(source._readableState.pipes.length, 0);
assert.strictEqual(source._readableState.flowing, false);
srcCheckEventNames.forEach((eventName) => {
for (const eventName of srcCheckEventNames) {
assert.strictEqual(
source.listenerCount(eventName), 0,
`source's '${eventName}' event listeners not removed`
);
});
}
});
function checkDestCleanup(dest) {
@ -65,13 +64,13 @@ assert.strictEqual(source._readableState.pipes.length, 0);
'listener which is `unpipeChecker`'
);
dest.removeListener('unpipe', unpipeChecker);
destCheckEventNames.forEach((eventName) => {
for (const eventName of destCheckEventNames) {
assert.strictEqual(
dest.listenerCount(eventName), 0,
`destination{${currentDestId}}'s '${eventName}' event ` +
'listeners not removed'
);
});
}
if (--destCount === 0)
checkSrcCleanup();