Skip to content

Commit 55a3a5f

Browse files
authored
Add extra Search Lazy Tests (#2107)
* Add extra Search Lazy Tests * Fix styling --------- Co-authored-by: lrljoe <[email protected]>
1 parent f6ebadc commit 55a3a5f

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

tests/Unit/Traits/Helpers/SearchHelpersTest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Helpers;
44

5+
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
56
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
67

78
final class SearchHelpersTest extends TestCase
@@ -148,4 +149,49 @@ public function test_can_trim_whitespace_from_search(): void
148149
$this->assertSame(' Anthony ', $this->basicTable->getSearch());
149150

150151
}
152+
153+
public function test_can_test_all_search_options(): void
154+
{
155+
$temp = new class extends PetsTable
156+
{
157+
public function resetSearchConfiguration(): self
158+
{
159+
$this->searchFilterBlur = null;
160+
$this->searchFilterDebounce = null;
161+
$this->searchFilterDefer = null;
162+
$this->searchFilterLazy = null;
163+
$this->searchFilterLive = null;
164+
$this->searchFilterThrottle = null;
165+
166+
return $this;
167+
}
168+
};
169+
170+
$this->assertFalse($temp->hasSearchDebounce());
171+
172+
$temp->setSearchDebounce(1000);
173+
174+
$this->assertSame('.live.debounce.1000ms', $temp->getSearchOptions());
175+
176+
$temp->resetSearchConfiguration()->setSearchDefer();
177+
178+
$this->assertSame('', $temp->getSearchOptions());
179+
180+
$temp->resetSearchConfiguration()->setSearchLive();
181+
182+
$this->assertSame('.live', $temp->getSearchOptions());
183+
184+
$temp->resetSearchConfiguration()->setSearchBlur();
185+
186+
$this->assertSame('.blur', $temp->getSearchOptions());
187+
188+
$temp->resetSearchConfiguration()->setSearchLazy();
189+
190+
$this->assertSame('.live.lazy', $temp->getSearchOptions());
191+
192+
$temp->resetSearchConfiguration()->setSearchThrottle(599);
193+
194+
$this->assertSame('.live.throttle.599ms', $temp->getSearchOptions());
195+
196+
}
151197
}

tests/Unit/Traits/Visuals/SearchVisualsTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ public function test_search_blur_filter_is_applied(): void
6262
->assertSeeHtml('wire:model.blur="search"');
6363
}
6464

65+
public function test_search_lazy_filter_is_applied(): void
66+
{
67+
Livewire::test(PetsTable::class)
68+
->assertDontSeeHtml('wire:model.live.lazy="search"')
69+
->call('setSearchLazy')
70+
->assertSeeHtml('wire:model.live.lazy="search"');
71+
}
72+
6573
public function test_search_defer_filter_is_applied(): void
6674
{
6775
Livewire::test(PetsTable::class)
@@ -72,7 +80,8 @@ public function test_search_defer_filter_is_applied(): void
7280
public function test_search_live_filter_is_applied(): void
7381
{
7482
Livewire::test(PetsTable::class)
75-
->assertDontSeeHtml('wire:model="search"')
83+
->call('setSearchLazy')
84+
->assertDontSeeHtml('wire:model.live="search"')
7685
->call('setSearchLive')
7786
->assertSeeHtml('wire:model.live="search"');
7887
}

0 commit comments

Comments
 (0)