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 <daijiro.wachi@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
This commit is contained in:
Luigi Pinca committed 2020-11-14 18:29:18 +01:00
1 parent 22293eab48
commit d5e4e19470
1 file changed
+5 -8
@@ -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());
}));