File tree Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ class InputPrompt extends Base {
101101 */
102102
103103 onKeypress ( ) {
104- this . state = 'touched' ;
104+ this . status = 'touched' ;
105105
106106 this . render ( ) ;
107107 }
Original file line number Diff line number Diff line change 2121 },
2222 "devDependencies" : {
2323 "chai" : " ^4.3.6" ,
24+ "chai-string" : " ^1.5.0" ,
2425 "chalk-pipe" : " ^5.1.1" ,
2526 "cmdify" : " ^0.0.4" ,
2627 "mocha" : " ^9.2.2" ,
Original file line number Diff line number Diff line change 11const { expect } = require ( 'chai' ) ;
2+ const chai = require ( 'chai' ) ;
3+ const chaiString = require ( 'chai-string' ) ;
24const ReadlineStub = require ( '../../helpers/readline' ) ;
35const fixtures = require ( '../../helpers/fixtures' ) ;
46
57const Input = require ( '../../../lib/prompts/input' ) ;
68
9+ chai . use ( chaiString ) ;
10+
711describe ( '`input` prompt' , ( ) => {
812 beforeEach ( function ( ) {
913 this . fixture = { ...fixtures . input } ;
@@ -94,4 +98,24 @@ describe('`input` prompt', () => {
9498 done ( ) ;
9599 } , 200 ) ;
96100 } ) ;
101+
102+ it ( 'should clear default on input' , function ( done ) {
103+ const defaultValue = 'default-string' ;
104+ const input = new Input (
105+ {
106+ ...this . fixture ,
107+ default : defaultValue ,
108+ } ,
109+ this . rl
110+ ) ;
111+
112+ input . run ( ) ;
113+
114+ this . rl . line = 'inquirer' ;
115+ this . rl . input . emit ( 'keypress' ) ;
116+ setTimeout ( ( ) => {
117+ expect ( this . rl . output . __raw__ ) . to . have . entriesCount ( defaultValue , 1 ) ;
118+ done ( ) ;
119+ } , 200 ) ;
120+ } ) ;
97121} ) ;
Original file line number Diff line number Diff line change @@ -2820,6 +2820,11 @@ caseless@~0.12.0:
28202820 resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
28212821 integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=
28222822
2823+ chai-string@^1.5.0 :
2824+ version "1.5.0"
2825+ resolved "https://registry.yarnpkg.com/chai-string/-/chai-string-1.5.0.tgz#0bdb2d8a5f1dbe90bc78ec493c1c1c180dd4d3d2"
2826+ integrity sha512-sydDC3S3pNAQMYwJrs6dQX0oBQ6KfIPuOZ78n7rocW0eJJlsHPh2t3kwW7xfwYA/1Bf6/arGtSUo16rxR2JFlw==
2827+
28232828chai@^4.3.6 :
28242829 version "4.3.6"
28252830 resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.6.tgz#ffe4ba2d9fa9d6680cc0b370adae709ec9011e9c"
You can’t perform that action at this time.
0 commit comments