diff --git a/tests/Unit/Traits/Helpers/SearchHelpersTest.php b/tests/Unit/Traits/Helpers/SearchHelpersTest.php index b9c0d153f..b04d8fed8 100644 --- a/tests/Unit/Traits/Helpers/SearchHelpersTest.php +++ b/tests/Unit/Traits/Helpers/SearchHelpersTest.php @@ -2,6 +2,7 @@ namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Helpers; +use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable; use Rappasoft\LaravelLivewireTables\Tests\TestCase; final class SearchHelpersTest extends TestCase @@ -148,4 +149,49 @@ public function test_can_trim_whitespace_from_search(): void $this->assertSame(' Anthony ', $this->basicTable->getSearch()); } + + public function test_can_test_all_search_options(): void + { + $temp = new class extends PetsTable + { + public function resetSearchConfiguration(): self + { + $this->searchFilterBlur = null; + $this->searchFilterDebounce = null; + $this->searchFilterDefer = null; + $this->searchFilterLazy = null; + $this->searchFilterLive = null; + $this->searchFilterThrottle = null; + + return $this; + } + }; + + $this->assertFalse($temp->hasSearchDebounce()); + + $temp->setSearchDebounce(1000); + + $this->assertSame('.live.debounce.1000ms', $temp->getSearchOptions()); + + $temp->resetSearchConfiguration()->setSearchDefer(); + + $this->assertSame('', $temp->getSearchOptions()); + + $temp->resetSearchConfiguration()->setSearchLive(); + + $this->assertSame('.live', $temp->getSearchOptions()); + + $temp->resetSearchConfiguration()->setSearchBlur(); + + $this->assertSame('.blur', $temp->getSearchOptions()); + + $temp->resetSearchConfiguration()->setSearchLazy(); + + $this->assertSame('.live.lazy', $temp->getSearchOptions()); + + $temp->resetSearchConfiguration()->setSearchThrottle(599); + + $this->assertSame('.live.throttle.599ms', $temp->getSearchOptions()); + + } } diff --git a/tests/Unit/Traits/Visuals/SearchVisualsTest.php b/tests/Unit/Traits/Visuals/SearchVisualsTest.php index d951d9b6f..c64876e32 100644 --- a/tests/Unit/Traits/Visuals/SearchVisualsTest.php +++ b/tests/Unit/Traits/Visuals/SearchVisualsTest.php @@ -62,6 +62,14 @@ public function test_search_blur_filter_is_applied(): void ->assertSeeHtml('wire:model.blur="search"'); } + public function test_search_lazy_filter_is_applied(): void + { + Livewire::test(PetsTable::class) + ->assertDontSeeHtml('wire:model.live.lazy="search"') + ->call('setSearchLazy') + ->assertSeeHtml('wire:model.live.lazy="search"'); + } + public function test_search_defer_filter_is_applied(): void { Livewire::test(PetsTable::class) @@ -72,7 +80,8 @@ public function test_search_defer_filter_is_applied(): void public function test_search_live_filter_is_applied(): void { Livewire::test(PetsTable::class) - ->assertDontSeeHtml('wire:model="search"') + ->call('setSearchLazy') + ->assertDontSeeHtml('wire:model.live="search"') ->call('setSearchLive') ->assertSeeHtml('wire:model.live="search"'); }