From 7925182c11113ae3e2ae6d80d6f589f64f9ec790 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Sun, 1 Dec 2024 03:36:09 +0000 Subject: [PATCH 1/2] Add extra Search Lazy Tests --- .../Unit/Traits/Helpers/SearchHelpersTest.php | 47 +++++++++++++++++++ .../Unit/Traits/Visuals/SearchVisualsTest.php | 11 ++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/tests/Unit/Traits/Helpers/SearchHelpersTest.php b/tests/Unit/Traits/Helpers/SearchHelpersTest.php index b9c0d153f..f747a36aa 100644 --- a/tests/Unit/Traits/Helpers/SearchHelpersTest.php +++ b/tests/Unit/Traits/Helpers/SearchHelpersTest.php @@ -3,6 +3,7 @@ namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Helpers; use Rappasoft\LaravelLivewireTables\Tests\TestCase; +use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable; final class SearchHelpersTest extends TestCase { @@ -148,4 +149,50 @@ 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"'); } From 887d962611401899e846d9ecd04d238e2f5f9f6d Mon Sep 17 00:00:00 2001 From: lrljoe Date: Sun, 1 Dec 2024 03:36:35 +0000 Subject: [PATCH 2/2] Fix styling --- tests/Unit/Traits/Helpers/SearchHelpersTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/Unit/Traits/Helpers/SearchHelpersTest.php b/tests/Unit/Traits/Helpers/SearchHelpersTest.php index f747a36aa..b04d8fed8 100644 --- a/tests/Unit/Traits/Helpers/SearchHelpersTest.php +++ b/tests/Unit/Traits/Helpers/SearchHelpersTest.php @@ -2,8 +2,8 @@ namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Helpers; -use Rappasoft\LaravelLivewireTables\Tests\TestCase; use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable; +use Rappasoft\LaravelLivewireTables\Tests\TestCase; final class SearchHelpersTest extends TestCase { @@ -162,7 +162,7 @@ public function resetSearchConfiguration(): self $this->searchFilterLazy = null; $this->searchFilterLive = null; $this->searchFilterThrottle = null; - + return $this; } }; @@ -193,6 +193,5 @@ public function resetSearchConfiguration(): self $this->assertSame('.live.throttle.599ms', $temp->getSearchOptions()); - } }