Skip to content

Commit 16a3590

Browse files
authored
Add SortingConfiguration Missing Test (rappasoft#2151)
* Add SortingConfiguration Missing Test * Fix styling * Force Workflows * Fix styling --------- Co-authored-by: lrljoe <[email protected]>
1 parent 41c0bd0 commit 16a3590

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

tests/Unit/Traits/Configuration/SortingConfigurationTest.php

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

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

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

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

9394
$this->assertTrue($this->basicTable->getSortingPillsStatus());
9495
}
96+
97+
public function test_default_sort_applies_correctly(): void
98+
{
99+
$tempDesc = new class extends PetsTable
100+
{
101+
public function configure(): void
102+
{
103+
parent::configure();
104+
$this->setSortingEnabled();
105+
$this->setDefaultSort('name', 'desc');
106+
}
107+
};
108+
$viewDesc = view('livewire-tables::datatable');
109+
110+
$tempDesc->boot();
111+
$tempDesc->bootedComponentUtilities();
112+
$tempDesc->bootedManagesFilters();
113+
$tempDesc->bootedWithColumns();
114+
$tempDesc->bootedWithColumnSelect();
115+
$tempDesc->bootedWithSecondaryHeader();
116+
$tempDesc->booted();
117+
$tempDesc->mountManagesFilters();
118+
$tempDesc->mountWithSorting();
119+
$tempDesc->renderingWithColumns($viewDesc, $viewDesc->getData());
120+
$tempDesc->renderingWithColumnSelect($viewDesc, $viewDesc->getData());
121+
$tempDesc->renderingWithCustomisations($viewDesc, $viewDesc->getData());
122+
$tempDesc->renderingWithData($viewDesc, $viewDesc->getData());
123+
$tempDesc->renderingWithFooter($viewDesc, $viewDesc->getData());
124+
$tempDesc->renderingWithReordering($viewDesc, $viewDesc->getData());
125+
$tempDesc->renderingWithPagination($viewDesc, $viewDesc->getData());
126+
$tempDesc->render();
127+
$this->assertSame(['name' => 'desc'], $tempDesc->getSorts());
128+
$this->assertSame('desc', $tempDesc->getSort('name'));
129+
130+
$tempAsc = new class extends PetsTable
131+
{
132+
public function configure(): void
133+
{
134+
parent::configure();
135+
$this->setSortingEnabled();
136+
$this->setDefaultSort('name', 'asc');
137+
}
138+
};
139+
$viewAsc = view('livewire-tables::datatable');
140+
$tempAsc->boot();
141+
$tempAsc->bootedComponentUtilities();
142+
$tempAsc->bootedManagesFilters();
143+
$tempAsc->bootedWithColumns();
144+
$tempAsc->bootedWithColumnSelect();
145+
$tempAsc->bootedWithSecondaryHeader();
146+
$tempAsc->booted();
147+
$tempAsc->mountManagesFilters();
148+
$tempAsc->mountWithSorting();
149+
$tempAsc->renderingWithColumns($viewAsc, $viewAsc->getData());
150+
$tempAsc->renderingWithColumnSelect($viewAsc, $viewAsc->getData());
151+
$tempAsc->renderingWithCustomisations($viewAsc, $viewAsc->getData());
152+
$tempAsc->renderingWithData($viewAsc, $viewAsc->getData());
153+
$tempAsc->renderingWithFooter($viewAsc, $viewAsc->getData());
154+
$tempAsc->renderingWithReordering($viewAsc, $viewAsc->getData());
155+
$tempAsc->renderingWithPagination($viewAsc, $viewAsc->getData());
156+
$tempAsc->render();
157+
$this->assertSame(['name' => 'asc'], $tempAsc->getSorts());
158+
$this->assertSame('asc', $tempAsc->getSort('name'));
159+
160+
}
95161
}

0 commit comments

Comments
 (0)