Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jessarcher committed Oct 11, 2023
1 parent 483e8dd commit 63d5ace
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 56 deletions.
21 changes: 3 additions & 18 deletions tests/Feature/MultiSearchPromptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
Prompt::assertOutputContains('Please choose green.');
});

it('support home key binding', function () {
Prompt::fake(['r', Key::UP, Key::HOME[0], Key::SPACE, Key::ENTER]);
it('supports the home and end keys while navigating options', function () {
Prompt::fake([Key::DOWN, Key::END[0], Key::SPACE, Key::HOME[0], Key::SPACE, Key::ENTER]);

$result = multisearch(
label: 'What are your favorite colors?',
Expand All @@ -161,22 +161,7 @@
]
);

expect($result)->toBe(['red']);
});

it('support end key binding', function () {
Prompt::fake(['r', Key::DOWN, Key::END[0], Key::SPACE, Key::ENTER]);

$result = multisearch(
label: 'What are your favorite colors?',
options: fn () => [
'red' => 'Red',
'green' => 'Green',
'blue' => 'Blue',
]
);

expect($result)->toBe(['blue']);
expect($result)->toBe(['blue', 'red']);
});

it('can fall back', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@
expect($result)->toBe(['green', 'blue']);
});

it('support home key binding', function () {
Prompt::fake([Key::HOME[0], Key::SPACE, Key::ENTER]);
it('supports the home and end keys', function () {
Prompt::fake([Key::END[0], Key::SPACE, Key::HOME[0], Key::SPACE, Key::ENTER]);

$result = multiselect(
label: 'What are your favorite colors?',
Expand All @@ -167,22 +167,7 @@
]
);

expect($result)->toBe(['red']);
});

it('support end key binding', function () {
Prompt::fake([Key::END[0], Key::SPACE, Key::ENTER]);

$result = multiselect(
label: 'What are your favorite colors?',
options: [
'red' => 'Red',
'green' => 'Green',
'blue' => 'Blue',
]
);

expect($result)->toBe(['blue']);
expect($result)->toBe(['blue', 'red']);
});

it('returns an empty array when non-interactive', function () {
Expand Down
14 changes: 7 additions & 7 deletions tests/Feature/SearchPromptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@
expect($result)->toBe('Blue');
});

it('select using the home key', function () {
Prompt::fake(['e', Key::UP, Key::HOME[0], Key::ENTER]);
it('supports the home key while navigating options', function () {
Prompt::fake(['r', Key::DOWN, Key::DOWN, Key::HOME[0], Key::ENTER]);

$result = search(
label: 'What is your favorite color?',
options: fn (string $value) => array_filter(
[
'Red',
'Green',
'Blue',
'Pink',
],
fn ($option) => str_contains(strtolower($option), strtolower($value)),
),
Expand All @@ -61,22 +61,22 @@
expect($result)->toBe('Red');
});

it('select using the end key', function () {
Prompt::fake(['e', Key::DOWN, Key::END[0], Key::ENTER]);
it('supports the end key while navigating options', function () {
Prompt::fake(['r', Key::DOWN, Key::END[0], Key::ENTER]);

$result = search(
label: 'What is your favorite color?',
options: fn (string $value) => array_filter(
[
'Red',
'Green',
'Blue',
'Pink',
],
fn ($option) => str_contains(strtolower($option), strtolower($value)),
),
);

expect($result)->toBe('Blue');
expect($result)->toBe('Green');
});

it('returns the key when an associative array is passed', function () {
Expand Down
5 changes: 2 additions & 3 deletions tests/Feature/SelectPromptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
expect($result)->toBe('Green');
});

it('support home key binding', function () {
it('supports the home key', function () {
Prompt::fake([Key::HOME[0], Key::ENTER]);

$result = select(
Expand All @@ -242,7 +242,7 @@
expect($result)->toBe('Red');
});

it('support end key binding', function () {
it('supports the end key', function () {
Prompt::fake([Key::END[0], Key::ENTER]);

$result = select(
Expand All @@ -252,7 +252,6 @@
'Green',
'Blue',
],
default: 'Red'
);

expect($result)->toBe('Blue');
Expand Down
20 changes: 10 additions & 10 deletions tests/Feature/SuggestPromptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@
expect($result)->toBe('Black');
});

it('select the input using the home key', function () {
Prompt::fake(['B', Key::UP, Key::HOME[0], Key::ENTER]);
it('supports the home key while navigating options', function () {
Prompt::fake([Key::DOWN, Key::DOWN, Key::HOME[0], Key::ENTER]);

$result = suggest('What is your favorite color?', [
'Brown',
'Black',
'Red',
'Blue',
'Green',
]);

expect($result)->toBe('Brown');
expect($result)->toBe('Red');
});

it('select the input using the end key', function () {
Prompt::fake(['B', Key::DOWN, Key::END[0], Key::ENTER]);
it('supports the end key while navigating options', function () {
Prompt::fake([Key::DOWN, Key::END[0], Key::ENTER]);

$result = suggest('What is your favorite color?', [
'Brown',
'Black',
'Red',
'Blue',
'Green',
]);

expect($result)->toBe('Blue');
expect($result)->toBe('Green');
});

it('accepts a callback', function () {
Expand Down

0 comments on commit 63d5ace

Please sign in to comment.