Skip to content

Commit c792e2a

Browse files
Italo A. CasasFishrock123
authored andcommitted
test: stream readableListening internal state
PR-URL: #9864 Refs: #8683 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent a92f2ad commit c792e2a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
3+
constcommon=require('../common');
4+
constassert=require('assert');
5+
conststream=require('stream');
6+
7+
constr=newstream.Readable({
8+
read: ()=>{}
9+
});
10+
11+
// readableListening state should start in `false`.
12+
assert.strictEqual(r._readableState.readableListening,false);
13+
14+
r.on('readable',common.mustCall(()=>{
15+
// Inside the readable event this state should be true.
16+
assert.strictEqual(r._readableState.readableListening,true);
17+
}));
18+
19+
r.push(Buffer.from('Testing readableListening state'));
20+
21+
constr2=newstream.Readable({
22+
read: ()=>{}
23+
});
24+
25+
// readableListening state should start in `false`.
26+
assert.strictEqual(r2._readableState.readableListening,false);
27+
28+
r2.on('data',common.mustCall((chunk)=>{
29+
// readableListening should be false because we don't have
30+
// a `readable` listener
31+
assert.strictEqual(r2._readableState.readableListening,false);
32+
}));
33+
34+
r2.push(Buffer.from('Testing readableListening state'));

0 commit comments

Comments
(0)