test: increase coverage of internal/stream/end-of-stream
This change adds test cases to call the function returned by end-of-stream and asserts that callbacks are not called when the stream is ended, or prematurely closed. PR-URL: https://github.com/nodejs/node/pull/23751 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
cc750b71a1
commit
7d2494d867
@ -153,3 +153,25 @@ const { promisify } = require('util');
|
|||||||
rs.push(null);
|
rs.push(null);
|
||||||
rs.resume();
|
rs.resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test that calling returned function removes listeners
|
||||||
|
{
|
||||||
|
const ws = new Writable({
|
||||||
|
write(data, env, cb) {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const removeListener = finished(ws, common.mustNotCall());
|
||||||
|
removeListener();
|
||||||
|
ws.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const rs = new Readable();
|
||||||
|
const removeListeners = finished(rs, common.mustNotCall());
|
||||||
|
removeListeners();
|
||||||
|
|
||||||
|
rs.emit('close');
|
||||||
|
rs.push(null);
|
||||||
|
rs.resume();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user