mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
test: increase coverage for stream's duplex
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: https://github.com/nodejs/node/pull/10963 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
1 parent
8ff15a262d
commit
174bef182a
1 file changed
+5
-4
@@ -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);
|
||||
});
|
||||
Reference in new issue
Block a user