Skip to content

Commit

Permalink
More testing for filters registration
Browse files Browse the repository at this point in the history
  • Loading branch information
afonic committed Jan 24, 2024
1 parent 0e4d47b commit a94808a
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/Feature/LivewireCollectionComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,57 @@ public function it_works_for_taxonomy_terms()
]);
}

/** @test */
public function check_that_filtering_works_when_filter_is_mounted()
{
$params = [
'from' => 'clothes',
];

Livewire::test(LivewireCollectionComponent::class, ['params' => $params])
->assertSet('collections', 'clothes')
->dispatch('filter-mounted',
field: 'colors',
condition: 'taxonomy',
modifier: 'any',
)
->dispatch('filter-updated',
field: 'colors',
condition: 'taxonomy',
payload: 'red',
command: 'add',
modifier: 'any',
)
->assertSet('params', [
'taxonomy:colors:any' => 'red',
])
->assertSee('Red Shirt')
->assertDontSee('Black Shirt');
}

/** @test */
public function check_that_filter_gets_ignored_if_not_registered()
{
$params = [
'from' => 'clothes',
];

Livewire::test(LivewireCollectionComponent::class, ['params' => $params])
->assertSet('collections', 'clothes')
->dispatch('filter-updated',
field: 'colors',
condition: 'taxonomy',
payload: 'red',
command: 'add',
modifier: 'any',
)
->assertSet('params', [
'taxonomy:colors:any' => 'red',
])
->assertSee('Yellow Shirt')
->assertSee('Black Shirt');
}

/** @test */
public function it_sets_query_scope_parameters()
{
Expand Down

0 comments on commit a94808a

Please sign in to comment.