Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
cerbero90 committed Jan 16, 2025
1 parent c3d1cd0 commit 0350665
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions tests/Feature/EnumMakeCommandTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?php

use Laravel\Prompts\Prompt;
use Laravel\Prompts\SelectPrompt;
use Laravel\Prompts\TextareaPrompt;
use Laravel\Prompts\TextPrompt;

it('succeeds if an enum already exists', function() {
$this
Expand Down Expand Up @@ -33,19 +30,15 @@
['SubDirectory\Generated3', null],
]);

// it('generates enums with prompts', function() {
// // Currently textarea() of Laravel Prompts seems to have some testing issues.
// // Apparently the method expectsQuestion() does not test textarea rightly.
// // In alternative, we fallback the prompt with the expected user input.
// // Prompt::fallbackWhen(true);
// // TextPrompt::fallbackUsing(fn() => 'App\Enums\Generated1');
// // SelectPrompt::fallbackUsing(fn() => 'bitwise');
// // TextareaPrompt::fallbackUsing(fn() => 'CaseOne' . PHP_EOL . 'CaseTwo');

// // $command = $this->artisan('enum:make')
// // ->expectsQuestion('The namespace of the enum', 'App\Enums\Generated1')
// // ->expectsQuestion('How cases should be backed', 'bitwise')
// // ->expectsQuestion('The cases (one per line)', 'CaseOne' . PHP_EOL . 'CaseTwo');

// expect($this->artisan('enum:make'))->toGenerate('App\Enums\Generated1');
// })->only();
it('generates enums with prompts', function() {
// Currently textarea() of Laravel Prompts seems to have some testing issues.
// Apparently the method expectsQuestion() does not test textarea rightly.
// In alternative, we fallback the prompt with the expected user input.
TextareaPrompt::fallbackUsing(fn() => 'CaseOne' . PHP_EOL . 'CaseTwo');

$command = $this->artisan('enum:make')
->expectsQuestion('The namespace of the enum', 'App\Enums\Generated1')
->expectsQuestion('How cases should be backed', 'bitwise');

expect($command)->toGenerate('App\Enums\Generated1');
});

0 comments on commit 0350665

Please sign in to comment.