From ac6a19d5c72036f45d728a3840c5e91a86d77348 Mon Sep 17 00:00:00 2001 From: Simon de Lang Date: Tue, 28 May 2019 11:09:40 +0200 Subject: [PATCH] fix(inquirer): fix inquirer types --- packages/core/src/initializer/StrykerInquirer.ts | 4 ++-- packages/core/src/initializer/presets/ReactPreset.ts | 2 +- packages/core/src/initializer/presets/VueJsPreset.ts | 4 ++-- .../core/test/unit/initializer/StrykerInitializer.spec.ts | 8 +++++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/core/src/initializer/StrykerInquirer.ts b/packages/core/src/initializer/StrykerInquirer.ts index ad926cc761..12648ff230 100644 --- a/packages/core/src/initializer/StrykerInquirer.ts +++ b/packages/core/src/initializer/StrykerInquirer.ts @@ -11,7 +11,7 @@ export interface PromptResult { export class StrykerInquirer { public async promptPresets(options: Preset[]): Promise { - const choices: inquirer.ChoiceType[] = options.map(_ => _.name); + const choices: inquirer.ChoiceType[] = options.map(_ => _.name); choices.push(new inquirer.Separator()); choices.push('None/other'); const answers = await inquirer.prompt<{ preset: string }>({ @@ -24,7 +24,7 @@ export class StrykerInquirer { } public async promptTestRunners(options: PromptOption[]): Promise { - const choices: inquirer.ChoiceType[] = options.map(_ => _.name); + const choices: inquirer.ChoiceType[] = options.map(_ => _.name); choices.push(new inquirer.Separator()); choices.push(CommandTestRunner.runnerName); const answers = await inquirer.prompt<{ testRunner: string }>({ diff --git a/packages/core/src/initializer/presets/ReactPreset.ts b/packages/core/src/initializer/presets/ReactPreset.ts index 00e73d9361..2601b2d027 100644 --- a/packages/core/src/initializer/presets/ReactPreset.ts +++ b/packages/core/src/initializer/presets/ReactPreset.ts @@ -39,7 +39,7 @@ export class ReactPreset implements Preset { }`; public async createConfig(): Promise { - const choices: inquirer.ChoiceType[] = ['JSX', 'TSX']; + const choices: inquirer.ChoiceType[] = ['JSX', 'TSX']; const answers = await inquirer.prompt<{ choice: string }>({ choices, message: 'Is your project a JSX project or a TSX project?', diff --git a/packages/core/src/initializer/presets/VueJsPreset.ts b/packages/core/src/initializer/presets/VueJsPreset.ts index 9cfcca4b02..26d1030d70 100644 --- a/packages/core/src/initializer/presets/VueJsPreset.ts +++ b/packages/core/src/initializer/presets/VueJsPreset.ts @@ -44,14 +44,14 @@ export class VueJsPreset implements Preset { }`; public async createConfig(): Promise { - const testRunnerChoices: inquirer.ChoiceType[] = ['karma', 'jest']; + const testRunnerChoices: inquirer.ChoiceType[] = ['karma', 'jest']; const testRunnerAnswers = await inquirer.prompt<{ testRunner: string }>({ choices: testRunnerChoices, message: 'Which test runner do you want to use?', name: 'testRunner', type: 'list' }); - const scriptChoices: inquirer.ChoiceType[] = ['typescript', 'javascript']; + const scriptChoices: inquirer.ChoiceType[] = ['typescript', 'javascript']; const scriptAnswers = await inquirer.prompt<{ script: string }>({ choices: scriptChoices, message: 'Which language does your project use?', diff --git a/packages/core/test/unit/initializer/StrykerInitializer.spec.ts b/packages/core/test/unit/initializer/StrykerInitializer.spec.ts index bccfcfccf5..1e3b41f7b4 100644 --- a/packages/core/test/unit/initializer/StrykerInitializer.spec.ts +++ b/packages/core/test/unit/initializer/StrykerInitializer.spec.ts @@ -93,14 +93,16 @@ describe(StrykerInitializer.name, () => { }); await sut.initialize(); expect(inquirerPrompt).callCount(7); - const [promptPreset, promptTestRunner, promptTestFramework, promptMutator, promptTranspilers, promptReporters, promptPackageManagers]: inquirer.Question[] = [ + const [promptPreset, promptTestRunner, promptTestFramework, promptMutator, promptPackageManagers]: inquirer.ListQuestion[] = [ inquirerPrompt.getCall(0).args[0], inquirerPrompt.getCall(1).args[0], inquirerPrompt.getCall(2).args[0], inquirerPrompt.getCall(3).args[0], + inquirerPrompt.getCall(6).args[0], + ]; + const [promptTranspilers, promptReporters]: inquirer.CheckboxQuestion[] = [ inquirerPrompt.getCall(4).args[0], inquirerPrompt.getCall(5).args[0], - inquirerPrompt.getCall(6).args[0], ]; expect(promptPreset.type).to.eq('list'); expect(promptPreset.name).to.eq('preset'); @@ -196,7 +198,7 @@ describe(StrykerInitializer.name, () => { }); await sut.initialize(); expect(inquirerPrompt).callCount(2); - const [promptPreset, promptPackageManager]: inquirer.Question[] = [ + const [promptPreset, promptPackageManager]: inquirer.ListQuestion[] = [ inquirerPrompt.getCall(0).args[0], inquirerPrompt.getCall(1).args[0] ];