Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra Search Lazy Tests #2107

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading