|
2 | 2 |
|
3 | 3 | namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Configuration; |
4 | 4 |
|
| 5 | +use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable; |
5 | 6 | use Rappasoft\LaravelLivewireTables\Tests\TestCase; |
6 | 7 |
|
7 | 8 | final class SortingConfigurationTest extends TestCase |
@@ -92,4 +93,69 @@ public function test_can_set_sorting_pill_status(): void |
92 | 93 |
|
93 | 94 | $this->assertTrue($this->basicTable->getSortingPillsStatus()); |
94 | 95 | } |
| 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 | + } |
95 | 161 | } |
0 commit comments