Skip to content

Commit

Permalink
Dispatch even when entries are updated
Browse files Browse the repository at this point in the history
  • Loading branch information
afonic committed Jan 20, 2024
1 parent f670473 commit f2599ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Http/Livewire/LivewireCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ protected function resetPagination()
public function entries()
{
$entries = (new Entries($this->generateParams()))->get();
$this->dispatch('entries-updated')->self();
if ($this->paginate) {
return $this->withPagination('entries', $entries);
}
Expand Down
4 changes: 4 additions & 0 deletions tests/Feature/LivewireCollectionComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public function it_loads_the_livewire_component_with_parameters_and_changes_them
'title:is' => 'I Love Guitars',
'item_options:is' => 'option1',
])
->assertDispatched('entries-updated')
->dispatch('filter-updated',
field: 'title',
condition: 'is',
Expand All @@ -105,6 +106,7 @@ public function it_loads_the_livewire_component_with_parameters_and_changes_them
'title:is' => 'Test',
'item_options:is' => 'option1',
])
->assertDispatched('entries-updated')
->dispatch('filter-updated',
field: 'item_options',
condition: 'is',
Expand All @@ -116,13 +118,15 @@ public function it_loads_the_livewire_component_with_parameters_and_changes_them
'title:is' => 'Test',
'item_options:is' => 'option1|option2',
])
->assertDispatched('entries-updated')
->dispatch('filter-updated',
field: 'item_options',
condition: 'is',
payload: 'option1',
command: 'remove',
modifier: 'any',
)
->assertDispatched('entries-updated')
->assertSet('params', [
'title:is' => 'Test',
'item_options:is' => 'option2',
Expand Down

0 comments on commit f2599ec

Please sign in to comment.