From be34b629decbbd9bb74294361528a996af48d18c Mon Sep 17 00:00:00 2001 From: abouthiroppy Date: Mon, 23 Jan 2017 22:27:00 +0900 Subject: [PATCH] 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 Reviewed-By: Anna Henningsen Reviewed-By: Italo A. Casas Reviewed-By: James M Snell Reviewed-By: Michael Dawson Reviewed-By: Luigi Pinca Reviewed-By: Matteo Collina --- test/parallel/test-stream-duplex.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-stream-duplex.js b/test/parallel/test-stream-duplex.js index 3760960ac9346c..0b71b3d9a50569 100644 --- a/test/parallel/test-stream-duplex.js +++ b/test/parallel/test-stream-duplex.js @@ -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() { - assert(read.val === 1); - assert(written.val === 2); +process.on('exit', () => { + assert.strictEqual(read.val, 1); + assert.strictEqual(written.val, 2); });