File tree 1 file changed +45
-0
lines changed
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const common = require ( '../common' ) ;
3
+ const { PassThrough } = require ( 'stream' ) ;
4
+ const readline = require ( 'readline' ) ;
5
+ const assert = require ( 'assert' ) ;
6
+
7
+ {
8
+ const input = new PassThrough ( ) ;
9
+ const rl = readline . createInterface ( {
10
+ terminal : true ,
11
+ input : input
12
+ } ) ;
13
+
14
+ rl . on ( 'line' , common . mustCall ( ( data ) => {
15
+ assert . strictEqual ( data , 'abc' ) ;
16
+ } ) ) ;
17
+
18
+ input . end ( 'abc' ) ;
19
+ }
20
+
21
+ {
22
+ const input = new PassThrough ( ) ;
23
+ const rl = readline . createInterface ( {
24
+ terminal : true ,
25
+ input : input
26
+ } ) ;
27
+
28
+ rl . on ( 'line' , common . mustNotCall ( 'must not be called before newline' ) ) ;
29
+
30
+ input . write ( 'abc' ) ;
31
+ }
32
+
33
+ {
34
+ const input = new PassThrough ( ) ;
35
+ const rl = readline . createInterface ( {
36
+ terminal : true ,
37
+ input : input
38
+ } ) ;
39
+
40
+ rl . on ( 'line' , common . mustCall ( ( data ) => {
41
+ assert . strictEqual ( data , 'abc' ) ;
42
+ } ) ) ;
43
+
44
+ input . write ( 'abc\n' ) ;
45
+ }
You can’t perform that action at this time.
0 commit comments