Skip to content

Commit

Permalink
Add SortingConfiguration Missing Test (#2151)
Browse files Browse the repository at this point in the history
* Add SortingConfiguration Missing Test

* Fix styling

* Force Workflows

* Fix styling

---------

Co-authored-by: lrljoe <[email protected]>
  • Loading branch information
lrljoe and lrljoe authored Jan 6, 2025
1 parent 41c0bd0 commit 16a3590
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions tests/Unit/Traits/Configuration/SortingConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Configuration;

use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;

final class SortingConfigurationTest extends TestCase
Expand Down Expand Up @@ -92,4 +93,69 @@ public function test_can_set_sorting_pill_status(): void

$this->assertTrue($this->basicTable->getSortingPillsStatus());
}

public function test_default_sort_applies_correctly(): void
{
$tempDesc = new class extends PetsTable
{
public function configure(): void
{
parent::configure();
$this->setSortingEnabled();
$this->setDefaultSort('name', 'desc');
}
};
$viewDesc = view('livewire-tables::datatable');

$tempDesc->boot();
$tempDesc->bootedComponentUtilities();
$tempDesc->bootedManagesFilters();
$tempDesc->bootedWithColumns();
$tempDesc->bootedWithColumnSelect();
$tempDesc->bootedWithSecondaryHeader();
$tempDesc->booted();
$tempDesc->mountManagesFilters();
$tempDesc->mountWithSorting();
$tempDesc->renderingWithColumns($viewDesc, $viewDesc->getData());
$tempDesc->renderingWithColumnSelect($viewDesc, $viewDesc->getData());
$tempDesc->renderingWithCustomisations($viewDesc, $viewDesc->getData());
$tempDesc->renderingWithData($viewDesc, $viewDesc->getData());
$tempDesc->renderingWithFooter($viewDesc, $viewDesc->getData());
$tempDesc->renderingWithReordering($viewDesc, $viewDesc->getData());
$tempDesc->renderingWithPagination($viewDesc, $viewDesc->getData());
$tempDesc->render();
$this->assertSame(['name' => 'desc'], $tempDesc->getSorts());
$this->assertSame('desc', $tempDesc->getSort('name'));

$tempAsc = new class extends PetsTable
{
public function configure(): void
{
parent::configure();
$this->setSortingEnabled();
$this->setDefaultSort('name', 'asc');
}
};
$viewAsc = view('livewire-tables::datatable');
$tempAsc->boot();
$tempAsc->bootedComponentUtilities();
$tempAsc->bootedManagesFilters();
$tempAsc->bootedWithColumns();
$tempAsc->bootedWithColumnSelect();
$tempAsc->bootedWithSecondaryHeader();
$tempAsc->booted();
$tempAsc->mountManagesFilters();
$tempAsc->mountWithSorting();
$tempAsc->renderingWithColumns($viewAsc, $viewAsc->getData());
$tempAsc->renderingWithColumnSelect($viewAsc, $viewAsc->getData());
$tempAsc->renderingWithCustomisations($viewAsc, $viewAsc->getData());
$tempAsc->renderingWithData($viewAsc, $viewAsc->getData());
$tempAsc->renderingWithFooter($viewAsc, $viewAsc->getData());
$tempAsc->renderingWithReordering($viewAsc, $viewAsc->getData());
$tempAsc->renderingWithPagination($viewAsc, $viewAsc->getData());
$tempAsc->render();
$this->assertSame(['name' => 'asc'], $tempAsc->getSorts());
$this->assertSame('asc', $tempAsc->getSort('name'));

}
}

0 comments on commit 16a3590

Please sign in to comment.