Skip to content

Commit

Permalink
Add extra Search Lazy Tests (#2107)
Browse files Browse the repository at this point in the history
* Add extra Search Lazy Tests

* Fix styling

---------

Co-authored-by: lrljoe <[email protected]>
  • Loading branch information
lrljoe and lrljoe authored Dec 1, 2024
1 parent f6ebadc commit 55a3a5f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
46 changes: 46 additions & 0 deletions tests/Unit/Traits/Helpers/SearchHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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());

}
}
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 55a3a5f

Please sign in to comment.