From 332c9a4430deb2d81749bd5e501c272c47552ba4 Mon Sep 17 00:00:00 2001 From: Dom Harrington Date: Mon, 8 Jul 2019 16:08:24 -0700 Subject: [PATCH] wip testing for enquirer --- lib/prompts.js | 4 ++-- test/prompts.test.js | 29 ++++++++++------------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/lib/prompts.js b/lib/prompts.js index 3bbadb822..4f73c8a5d 100644 --- a/lib/prompts.js +++ b/lib/prompts.js @@ -1,7 +1,7 @@ const { prompt } = require('enquirer'); exports.generatePrompts = (versionList) => - prompt([ + [ { type: 'select', name: 'option', @@ -27,7 +27,7 @@ exports.generatePrompts = (versionList) => }; }), }, - ]); + ]; exports.createVersionPrompt = async (versionList, opts, isUpdate) => prompt([ diff --git a/test/prompts.test.js b/test/prompts.test.js index d3b6faf05..60a5e13b3 100644 --- a/test/prompts.test.js +++ b/test/prompts.test.js @@ -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 () => {