File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const common = require ( '../common' ) ;
4
+ const assert = require ( 'assert' ) ;
5
+ const stream = require ( 'stream' ) ;
6
+
7
+ const r = new stream . 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
+ const r2 = new stream . 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' ) ) ;
You can’t perform that action at this time.
0 commit comments