-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #201 from form8ion/alpha
- Loading branch information
Showing
18 changed files
with
130 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import inquirer from 'inquirer'; | ||
import * as prompts from '@form8ion/overridable-prompts'; | ||
import any from '@travi/any'; | ||
import {assert} from 'chai'; | ||
import sinon from 'sinon'; | ||
import {questionNames} from '../../../prompts/question-names'; | ||
import prompt from './prompt'; | ||
|
||
suite('bundler prompt', () => { | ||
let sandbox; | ||
|
||
setup(() => { | ||
sandbox = sinon.createSandbox(); | ||
|
||
sandbox.stub(prompts, 'prompt'); | ||
}); | ||
|
||
teardown(() => sandbox.restore()); | ||
|
||
test('that the choice of package bundlers is presented', async () => { | ||
const chosenType = any.word(); | ||
const decisions = any.simpleObject(); | ||
const answers = {...any.simpleObject(), [questionNames.PACKAGE_BUNDLER]: chosenType}; | ||
const bundlers = any.simpleObject(); | ||
prompts.prompt | ||
.withArgs([{ | ||
name: questionNames.PACKAGE_BUNDLER, | ||
type: 'list', | ||
message: 'Which bundler should be used?', | ||
choices: [...Object.keys(bundlers), new inquirer.Separator(), 'Other'] | ||
}], decisions) | ||
.resolves(answers); | ||
|
||
assert.equal(await prompt({bundlers, decisions}), chosenType); | ||
}); | ||
|
||
test('that the prompt is skipped and `Other` is returned when no options ar provided ', async () => { | ||
assert.equal(await prompt({bundlers: {}}), 'Other'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {Separator} from 'inquirer'; | ||
import {prompt} from '@form8ion/overridable-prompts'; | ||
import {questionNames} from '../../../prompts/question-names'; | ||
|
||
export default async function ({bundlers, decisions}) { | ||
if (!Object.keys(bundlers).length) return 'Other'; | ||
|
||
const answers = await prompt([{ | ||
name: questionNames.PACKAGE_BUNDLER, | ||
type: 'list', | ||
message: 'Which bundler should be used?', | ||
choices: [...Object.keys(bundlers), new Separator(), 'Other'] | ||
}], decisions); | ||
|
||
return answers[questionNames.PACKAGE_BUNDLER]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.