Skip to content

Commit

Permalink
test: increase coverage of internal/stream/end-of-stream
Browse files Browse the repository at this point in the history
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: #23751
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
lrdcasimir authored and rvagg committed Nov 28, 2018
1 parent b609565 commit 1d201be
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/parallel/test-stream-finished.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,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();
}

0 comments on commit 1d201be

Please sign in to comment.