From 8516c2ef9063e5c09ac770ea3974c91838629e14 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Mon, 9 Nov 2020 21:23:50 +0100 Subject: [PATCH] test: improve test-stream-duplex-readable-end - Remove unneeded listener for the `'error'` event. - Use `common.mustCall()`. - Verify that the `src` stream gets paused. PR-URL: https://github.com/nodejs/node/pull/36056 Refs: https://github.com/nodejs/node/pull/35941 Reviewed-By: Daijiro Wachi Reviewed-By: Rich Trott Reviewed-By: Benjamin Gruenbaum Reviewed-By: Ricky Zhou <0x19951125@gmail.com> --- test/parallel/test-stream-duplex-readable-end.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-stream-duplex-readable-end.js b/test/parallel/test-stream-duplex-readable-end.js index ca3ccf63c49474..0e3e62aacb14bc 100644 --- a/test/parallel/test-stream-duplex-readable-end.js +++ b/test/parallel/test-stream-duplex-readable-end.js @@ -1,6 +1,6 @@ 'use strict'; // https://github.com/nodejs/node/issues/35926 -require('../common'); +const common = require('../common'); const assert = require('assert'); const stream = require('stream'); @@ -22,11 +22,8 @@ const dst = new stream.Transform({ src.pipe(dst); -function parser_end() { - assert.ok(loops > 0); - dst.removeAllListeners(); -} - dst.on('data', () => { }); -dst.on('end', parser_end); -dst.on('error', parser_end); +dst.on('end', common.mustCall(() => { + assert.strictEqual(loops, 3); + assert.ok(src.isPaused()); +}));