diff options
author | Matteo Collina <hello@matteocollina.com> | 2019-02-11 13:20:26 +0100 |
---|---|---|
committer | Matteo Collina <hello@matteocollina.com> | 2019-03-06 08:38:29 +0000 |
commit | e95e7f9af540c88e93701ff6ca2f38986deb8e99 (patch) | |
tree | 26ae5c394ee060abd4437b54ca160a11a5a9f1e2 /test/parallel/test-stream-readable-emittedReadable.js | |
parent | d38cd82513584c9d7c463aa809e5ee483a66eae3 (diff) | |
download | android-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.js | 13 |
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'); |