Skip to content

Commit

Permalink
chore: cleaning up some funky test logic
Browse files Browse the repository at this point in the history
  • Loading branch information
erunion committed Oct 5, 2021
1 parent 0e55604 commit 3144e64
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions __tests__/lib/prompts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,21 @@ describe('prompt test bed', () => {
describe('generatePrompts()', () => {
it('should not allow selection of version if chosen to create new version', async () => {
enquirer.on('prompt', async prompt => {
if (prompt.name === 'option') {
await prompt.keypress(null, { name: 'down' });
await prompt.submit();
}

// eslint-disable-next-line jest/no-if
if (prompt.name === 'versionSelection') {
expect(await prompt.skip()).toBe(true);
}

if (prompt.name === 'newVersion') {
// eslint-disable-next-line no-param-reassign
prompt.value = '1.2.1';
await prompt.submit();
// eslint-disable-next-line default-case
switch (prompt.name) {
case 'option':
await prompt.keypress(null, { name: 'down' });
await prompt.submit();
break;

case 'versionSelection':
await expect(prompt.skip()).resolves.toBe(true);
break;

case 'newVersion':
// eslint-disable-next-line no-param-reassign
prompt.value = '1.2.1';
await prompt.submit();
}
});

Expand Down

0 comments on commit 3144e64

Please sign in to comment.