Skip to content

Commit

Permalink
wip testing for enquirer
Browse files Browse the repository at this point in the history
  • Loading branch information
domharrington committed Jul 8, 2019
1 parent c3a5331 commit 332c9a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
4 changes: 2 additions & 2 deletions lib/prompts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { prompt } = require('enquirer');

exports.generatePrompts = (versionList) =>
prompt([
[
{
type: 'select',
name: 'option',
Expand All @@ -27,7 +27,7 @@ exports.generatePrompts = (versionList) =>
};
}),
},
]);
];

exports.createVersionPrompt = async (versionList, opts, isUpdate) =>
prompt([
Expand Down
29 changes: 10 additions & 19 deletions test/prompts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,25 @@ describe('prompt test bed', () => {
let enquirer;

beforeEach(() => {
enquirer = new Enquirer();
enquirer = new Enquirer({ show: false });
});

describe('generatePrompts()', () => {
it('should return a version if update is selected', async () => {
enquirer.on('prompt', async prompt => {
await prompt.submit();
// if (prompt.name === 'option') {
// prompt.submit()
// } else {
// prompt.value = 'red';
// prompt.submit();
// }
});

// return enquirer.prompt([{
// type: 'input',
// name: 'color',
// message: 'Favorite color?'
// }]).then(answers => console.log(answers));
if (prompt.name === 'option') {
await prompt.keypress(null, { name: 'down' });
// await prompt.keypress(null, { name: 'up' });
await prompt.submit()
}

if (prompt.name === 'versionSelection') {
assert.equal(await prompt.skip(), true);
}
});

return enquirer.prompt(promptHandler.generatePrompts(versionlist))
.then(answers => console.log(answers))

// const promptCall = await
// assert.equal(promptCall.versionSelection, '1');
// done();
});

// it('should return a create option if selected', async () => {
Expand Down

0 comments on commit 332c9a4

Please sign in to comment.