File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -1061,6 +1061,16 @@ for (let i = 0; i < 12; i++) {
1061
1061
rli . close ( ) ;
1062
1062
}
1063
1063
1064
+ // Calling only the first question callback
1065
+ {
1066
+ const [ rli ] = getInterface ( { terminal } ) ;
1067
+ rli . question ( 'foo?' , common . mustCall ( ( answer ) => {
1068
+ assert . strictEqual ( answer , 'bar' ) ;
1069
+ } ) ) ;
1070
+ rli . question ( 'hello?' , common . mustNotCall ( ) ) ;
1071
+ rli . write ( 'bar\n' ) ;
1072
+ }
1073
+
1064
1074
// Calling the question multiple times
1065
1075
{
1066
1076
const [ rli ] = getInterface ( { terminal } ) ;
@@ -1329,6 +1339,26 @@ for (let i = 0; i < 12; i++) {
1329
1339
rli . close ( ) ;
1330
1340
} ) , delay ) ;
1331
1341
}
1342
+
1343
+ // Write correctly if paused
1344
+ {
1345
+ const [ rli ] = getInterface ( { terminal } ) ;
1346
+ rli . on ( 'line' , common . mustCall ( ( line ) => {
1347
+ assert . strictEqual ( line , 'bar' ) ;
1348
+ } ) ) ;
1349
+ rli . pause ( ) ;
1350
+ rli . write ( 'bar\n' ) ;
1351
+ assert . strictEqual ( rli . paused , false ) ;
1352
+ rli . close ( ) ;
1353
+ }
1354
+
1355
+ // Write undefined
1356
+ {
1357
+ const [ rli ] = getInterface ( { terminal } ) ;
1358
+ rli . on ( 'line' , common . mustNotCall ( ) ) ;
1359
+ rli . write ( ) ;
1360
+ rli . close ( ) ;
1361
+ }
1332
1362
} ) ;
1333
1363
1334
1364
// Ensure that the _wordLeft method works even for large input
You can’t perform that action at this time.
0 commit comments