Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
lrdcasimir committed Oct 19, 2018
commit 937345fc0c1b7f7394d5dcc6286abd5cf34d6cf7
22 changes: 22 additions & 0 deletions test/parallel/test-stream-finished.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,25 @@ const { promisify } = require('util');
rs.push(null);
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();
}