summaryrefslogtreecommitdiff
path: root/test/parallel/test-stream-readable-emittedReadable.js
diff options
context:
space:
mode:
authorMatteo Collina <hello@matteocollina.com>2019-02-11 13:20:26 +0100
committerMatteo Collina <hello@matteocollina.com>2019-03-06 08:38:29 +0000
commite95e7f9af540c88e93701ff6ca2f38986deb8e99 (patch)
tree26ae5c394ee060abd4437b54ca160a11a5a9f1e2 /test/parallel/test-stream-readable-emittedReadable.js
parentd38cd82513584c9d7c463aa809e5ee483a66eae3 (diff)
downloadandroid-node-v8-e95e7f9af540c88e93701ff6ca2f38986deb8e99.tar.gz
android-node-v8-e95e7f9af540c88e93701ff6ca2f38986deb8e99.tar.bz2
android-node-v8-e95e7f9af540c88e93701ff6ca2f38986deb8e99.zip
stream: make sure 'readable' is emitted before ending the stream
Fixes: https://github.com/nodejs/node/issues/25810 PR-URL: https://github.com/nodejs/node/pull/26059 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test/parallel/test-stream-readable-emittedReadable.js')
-rw-r--r--test/parallel/test-stream-readable-emittedReadable.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/parallel/test-stream-readable-emittedReadable.js b/test/parallel/test-stream-readable-emittedReadable.js
index 5b9affc59f..167904e592 100644
--- a/test/parallel/test-stream-readable-emittedReadable.js
+++ b/test/parallel/test-stream-readable-emittedReadable.js
@@ -43,12 +43,23 @@ const noRead = new Readable({
read: () => {}
});
-noRead.on('readable', common.mustCall(() => {
+noRead.once('readable', common.mustCall(() => {
// emittedReadable should be true when the readable event is emitted
assert.strictEqual(noRead._readableState.emittedReadable, true);
noRead.read(0);
// emittedReadable is not reset during read(0)
assert.strictEqual(noRead._readableState.emittedReadable, true);
+
+ noRead.on('readable', common.mustCall(() => {
+ // The second 'readable' is emitted because we are ending
+
+ // emittedReadable should be true when the readable event is emitted
+ assert.strictEqual(noRead._readableState.emittedReadable, false);
+ noRead.read(0);
+ // emittedReadable is not reset during read(0)
+ assert.strictEqual(noRead._readableState.emittedReadable, false);
+
+ }));
}));
noRead.push('foo');