File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -1010,6 +1010,16 @@ for (let i = 0; i < 12; i++) {
1010
1010
rli . close ( ) ;
1011
1011
}
1012
1012
1013
+ // Calling only the first question callback
1014
+ {
1015
+ const [ rli ] = getInterface ( { terminal } ) ;
1016
+ rli . question ( 'foo?' , common . mustCall ( ( answer ) => {
1017
+ assert . strictEqual ( answer , 'bar' ) ;
1018
+ } ) ) ;
1019
+ rli . question ( 'hello?' , common . mustNotCall ( ) ) ;
1020
+ rli . write ( 'bar\n' ) ;
1021
+ }
1022
+
1013
1023
// Calling the question multiple times
1014
1024
{
1015
1025
const [ rli ] = getInterface ( { terminal } ) ;
@@ -1232,6 +1242,26 @@ for (let i = 0; i < 12; i++) {
1232
1242
rli . close ( ) ;
1233
1243
} ) , delay ) ;
1234
1244
}
1245
+
1246
+ // Write correctly if paused
1247
+ {
1248
+ const [ rli ] = getInterface ( { terminal } ) ;
1249
+ rli . on ( 'line' , common . mustCall ( ( line ) => {
1250
+ assert . strictEqual ( line , 'bar' ) ;
1251
+ } ) ) ;
1252
+ rli . pause ( ) ;
1253
+ rli . write ( 'bar\n' ) ;
1254
+ assert . strictEqual ( rli . paused , false ) ;
1255
+ rli . close ( ) ;
1256
+ }
1257
+
1258
+ // Write undefined
1259
+ {
1260
+ const [ rli ] = getInterface ( { terminal } ) ;
1261
+ rli . on ( 'line' , common . mustNotCall ( ) ) ;
1262
+ rli . write ( ) ;
1263
+ rli . close ( ) ;
1264
+ }
1235
1265
} ) ;
1236
1266
1237
1267
// Ensure that the _wordLeft method works even for large input
You can’t perform that action at this time.
0 commit comments