Skip to content

Commit

Permalink
Support for Livewire 3 (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
yazeed authored Nov 8, 2023
1 parent c633a86 commit 8b31d25
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.1]
laravel: ['9.50', 10]
php: [8.1, 8.2]
laravel: [10]
coverage-driver: [pcov]
stability: [prefer-lowest, prefer-stable]

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
}
],
"require": {
"php": "^8.1",
"livewire/livewire": "^2.0",
"illuminate/contracts": "^9.5|^10.0",
"illuminate/database": "^9.5|^10.0",
"illuminate/support": "^9.5|^10.0"
"php": "^8.1|^8.2",
"livewire/livewire": "^3.1",
"illuminate/contracts": "^10.0",
"illuminate/database": "^10.0",
"illuminate/support": "^10.0"
},
"require-dev": {
"orchestra/testbench": "^7.5|^8.0",
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Combobox.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ protected function selectModel(mixed $model, bool $silent = false): void {
}

if (!$silent) {
$this->emitUp("selected-$this->name", $model);
$this->dispatch("selected-$this->name", $model);
}
}

Expand All @@ -172,6 +172,6 @@ protected function selectModel(mixed $model, bool $silent = false): void {
protected function clearSelection(): void {
$this->selected = null;

$this->emitUp("cleared-$this->name");
$this->dispatch("cleared-$this->name");
}
}
8 changes: 4 additions & 4 deletions tests/AllowCreationComboboxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ public function test_can_create_new_models(): void {
$component->assertSuccessful()
->assertSee('Posts')
->assertSee('Create <b>Another Post</b>', false)
->assertNotEmitted('selected-posts')
->assertNotEmitted('cleared-posts');
->assertNotDispatched('selected-posts')
->assertNotDispatched('cleared-posts');

$this->assertDatabaseCount('posts', 3);

$component->call('create');

$post = Post::query()->where('title', 'Another Post')->first();

$component->assertEmitted('selected-posts')
->assertNotEmitted('cleared-posts')
$component->assertDispatched('selected-posts')
->assertNotDispatched('cleared-posts')
->assertSet('selected', $post);

$this->assertDatabaseCount('posts', 4);
Expand Down
44 changes: 22 additions & 22 deletions tests/BasicComboboxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function test_can_render(): void {
$component->assertSee('Users');
$component->assertSee('Select a user');

$component->assertNotEmitted('selected-users');
$component->assertNotEmitted('cleared-users');
$component->assertNotDispatched('selected-users');
$component->assertNotDispatched('cleared-users');
}

/**
Expand All @@ -50,8 +50,8 @@ public function test_can_render_available_results(): void {
$component->assertSee('User C');
$component->assertDontSee('Other');

$component->assertNotEmitted('selected-users');
$component->assertNotEmitted('cleared-users');
$component->assertNotDispatched('selected-users');
$component->assertNotDispatched('cleared-users');
}

/**
Expand All @@ -74,8 +74,8 @@ public function test_can_select_automatically_the_only_option(): void {
$component->assertDontSee('User C');
$component->assertSee('Other');

$component->assertEmittedUp('selected-users');
$component->assertNotEmitted('cleared-users');
$component->assertDispatched('selected-users');
$component->assertNotDispatched('cleared-users');
}

/**
Expand All @@ -101,8 +101,8 @@ public function test_an_option_can_be_selected(): void {
$component->assertDontSee('User C');
$component->assertDontSee('Other');

$component->assertEmittedUp('selected-users');
$component->assertNotEmitted('cleared-users');
$component->assertDispatched('selected-users');
$component->assertNotDispatched('cleared-users');
}

/**
Expand All @@ -127,8 +127,8 @@ public function test_selected_option_is_cleared_when_the_search_has_changed(): v
$component->assertDontSee('User C');
$component->assertDontSee('Other');

$component->assertEmittedUp('selected-users');
$component->assertNotEmitted('cleared-users');
$component->assertDispatched('selected-users');
$component->assertNotDispatched('cleared-users');

$component = $component->set('search', 'User');

Expand All @@ -140,8 +140,8 @@ public function test_selected_option_is_cleared_when_the_search_has_changed(): v
$component->assertSee('User C');
$component->assertDontSee('Other');

$component->assertNotEmitted('selected-users');
$component->assertEmittedUp('cleared-users');
$component->assertNotDispatched('selected-users');
$component->assertDispatched('cleared-users');
}

/**
Expand All @@ -166,8 +166,8 @@ public function test_selected_option_is_cleared_when_the_search_has_been_cleared
$component->assertDontSee('User C');
$component->assertDontSee('Other');

$component->assertEmittedUp('selected-users');
$component->assertNotEmitted('cleared-users');
$component->assertDispatched('selected-users');
$component->assertNotDispatched('cleared-users');

$component = $component->set('search', '');

Expand All @@ -179,8 +179,8 @@ public function test_selected_option_is_cleared_when_the_search_has_been_cleared
$component->assertDontSee('User C');
$component->assertDontSee('Other');

$component->assertNotEmitted('selected-users');
$component->assertEmittedUp('cleared-users');
$component->assertNotDispatched('selected-users');
$component->assertDispatched('cleared-users');
}

public function test_can_render_with_a_custom_search_placeholder(): void {
Expand Down Expand Up @@ -214,8 +214,8 @@ public function test_can_be_mounted_with_an_initial_model(): void {
$component->assertDontSee('User C');
$component->assertDontSee('Other');

$component->assertEmittedUp('selected-users');
$component->assertNotEmitted('cleared-users');
$component->assertDispatched('selected-users');
$component->assertNotDispatched('cleared-users');

$component = $component->set('search', 'User');

Expand All @@ -226,8 +226,8 @@ public function test_can_be_mounted_with_an_initial_model(): void {
$component->assertSee('User C');
$component->assertDontSee('Other');

$component->assertNotEmitted('selected-users');
$component->assertEmittedUp('cleared-users');
$component->assertNotDispatched('selected-users');
$component->assertDispatched('cleared-users');
}

public function test_initial_value_ignored_if_not_an_instance_of_search_model(): void {
Expand All @@ -244,7 +244,7 @@ public function test_initial_value_ignored_if_not_an_instance_of_search_model():
$component->assertSee('Users');
$component->assertSee('Select an option');

$component->assertNotEmitted('selected-users');
$component->assertNotEmitted('cleared-users');
$component->assertNotDispatched('selected-users');
$component->assertNotDispatched('cleared-users');
}
}
8 changes: 4 additions & 4 deletions tests/DontKeepSelectionComboboxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public function test_resets_properties_when_keep_selection_is_false(): void {
->assertSee('User B')
->assertSee('User C')
->assertDontSee('Other')
->assertNotEmitted('selected-users')
->assertNotEmitted('cleared-users');
->assertNotDispatched('selected-users')
->assertNotDispatched('cleared-users');

$component->call('select', 1)
->assertEmittedUp('selected-users')
->assertNotEmitted('cleared-users')
->assertDispatched('selected-users')
->assertNotDispatched('cleared-users')
->assertSet('selected', null);
}
}
Binary file modified tests/database/database.sqlite
Binary file not shown.

0 comments on commit 8b31d25

Please sign in to comment.