Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/inquirer/lib/prompts/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class InputPrompt extends Base {
*/

onKeypress() {
this.state = 'touched';
this.status = 'touched';

this.render();
}
Expand Down
1 change: 1 addition & 0 deletions packages/inquirer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"devDependencies": {
"chai": "^4.3.6",
"chai-string": "^1.5.0",
"chalk-pipe": "^5.1.1",
"cmdify": "^0.0.4",
"mocha": "^9.2.2",
Expand Down
24 changes: 24 additions & 0 deletions packages/inquirer/test/specs/prompts/input.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const { expect } = require('chai');
const chai = require('chai');
const chaiString = require('chai-string');
const ReadlineStub = require('../../helpers/readline');
const fixtures = require('../../helpers/fixtures');

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

chai.use(chaiString);

describe('`input` prompt', () => {
beforeEach(function () {
this.fixture = { ...fixtures.input };
Expand Down Expand Up @@ -94,4 +98,24 @@ describe('`input` prompt', () => {
done();
}, 200);
});

it('should clear default on input', function (done) {
const defaultValue = 'default-string';
const input = new Input(
{
...this.fixture,
default: defaultValue,
},
this.rl
);

input.run();

this.rl.line = 'inquirer';
this.rl.input.emit('keypress');
setTimeout(() => {
expect(this.rl.output.__raw__).to.have.entriesCount(defaultValue, 1);
done();
}, 200);
});
});
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2820,6 +2820,11 @@ caseless@~0.12.0:
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=

chai-string@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/chai-string/-/chai-string-1.5.0.tgz#0bdb2d8a5f1dbe90bc78ec493c1c1c180dd4d3d2"
integrity sha512-sydDC3S3pNAQMYwJrs6dQX0oBQ6KfIPuOZ78n7rocW0eJJlsHPh2t3kwW7xfwYA/1Bf6/arGtSUo16rxR2JFlw==

chai@^4.3.6:
version "4.3.6"
resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.6.tgz#ffe4ba2d9fa9d6680cc0b370adae709ec9011e9c"
Expand Down