Skip to content

Commit

Permalink
Add extra Search Lazy Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lrljoe authored Dec 1, 2024
1 parent f6ebadc commit 7925182
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
47 changes: 47 additions & 0 deletions tests/Unit/Traits/Helpers/SearchHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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());


}
}
11 changes: 10 additions & 1 deletion tests/Unit/Traits/Visuals/SearchVisualsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"');
}
Expand Down

0 comments on commit 7925182

Please sign in to comment.