Skip to content

Commit d53072c

Browse files
authored
Legacy fix default clearing on input (#1177)
1 parent b41b898 commit d53072c

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

packages/inquirer/lib/prompts/input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}

packages/inquirer/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
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",

packages/inquirer/test/specs/prompts/input.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
const { expect } = require('chai');
2+
const chai = require('chai');
3+
const chaiString = require('chai-string');
24
const ReadlineStub = require('../../helpers/readline');
35
const fixtures = require('../../helpers/fixtures');
46

57
const Input = require('../../../lib/prompts/input');
68

9+
chai.use(chaiString);
10+
711
describe('`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
});

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
28232828
chai@^4.3.6:
28242829
version "4.3.6"
28252830
resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.6.tgz#ffe4ba2d9fa9d6680cc0b370adae709ec9011e9c"

0 commit comments

Comments
 (0)