node/test/parallel/test-stream-duplex-readable-end.js
Luigi Pinca d5e4e19470 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>
2020-11-14 18:29:18 +01:00

30 lines
547 B
JavaScript

'use strict';
// https://github.com/nodejs/node/issues/35926
const common = require('../common');
const assert = require('assert');
const stream = require('stream');
let loops = 5;
const src = new stream.Readable({
read() {
if (loops--)
this.push(Buffer.alloc(20000));
}
});
const dst = new stream.Transform({
transform(chunk, output, fn) {
this.push(null);
fn();
}
});
src.pipe(dst);
dst.on('data', () => { });
dst.on('end', common.mustCall(() => {
assert.strictEqual(loops, 3);
assert.ok(src.isPaused());
}));