Skip to content

Commit

Permalink
test: increase coverage for stream's duplex
Browse files Browse the repository at this point in the history
Make use of Arrow function.
Add a small test and this file's coverage is 100%.
https://github.com/nodejs/node/blob/a647d82f83ad5ddad5db7be2cc24c3d686121792/lib/_stream_duplex.js#L25
Coverage: https://coverage.nodejs.org/coverage-067be658f966dafe/root/_stream_duplex.js.html

PR-URL: #10963
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Italo A. Casas <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
hiroppy authored and evanlucas committed Jan 31, 2017
1 parent b5e8413 commit f3efaee
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/parallel/test-stream-duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,28 @@ const Duplex = require('stream').Transform;

const stream = new Duplex({ objectMode: true });

assert(Duplex() instanceof Duplex);
assert(stream._readableState.objectMode);
assert(stream._writableState.objectMode);

let written;
let read;

stream._write = function(obj, _, cb) {
stream._write = (obj, _, cb) => {
written = obj;
cb();
};

stream._read = function() {};
stream._read = () => {};

stream.on('data', function(obj) {
stream.on('data', (obj) => {
read = obj;
});

stream.push({ val: 1 });
stream.end({ val: 2 });

process.on('exit', function() {
process.on('exit', () => {
assert.strictEqual(read.val, 1);
assert.strictEqual(written.val, 2);
});

0 comments on commit f3efaee

Please sign in to comment.