Skip to content

Commit 43e8146

Browse files
committed
Add test for No Columns
1 parent 4aa03fa commit 43e8146

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

tests/Unit/Traits/Helpers/ColumnHelpersTest.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

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

5-
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
6-
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
5+
use Rappasoft\LaravelLivewireTables\Exceptions\NoColumnsException;
76
use Rappasoft\LaravelLivewireTables\Views\Column;
87
use Rappasoft\LaravelLivewireTables\Views\Filters\TextFilter;
8+
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
9+
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
10+
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
911

1012
final class ColumnHelpersTest extends TestCase
1113
{
@@ -360,4 +362,28 @@ public function test_can_check_if_column_label_has_attributes(): void
360362
$this->assertSame(['class' => 'text-xl', 'default' => true, 'default-colors' => false, 'default-styling' => false], $column->getLabelAttributes());
361363

362364
}
365+
366+
public function test_throws_error_if_no_columns_are_defined(): void
367+
{
368+
$this->expectException(NoColumnsException::class);
369+
370+
$testTable = new class extends PetsTable
371+
{
372+
public function columns(): array
373+
{
374+
return [];
375+
}
376+
};
377+
378+
$testTable->configure();
379+
$testTable->boot();
380+
$testTable->bootedComponentUtilities();
381+
$testTable->bootedWithData();
382+
$testTable->bootedWithColumns();
383+
$testTable->bootedWithColumnSelect();
384+
$testTable->bootedWithSecondaryHeader();
385+
$testTable->booted();
386+
387+
}
388+
363389
}

0 commit comments

Comments
 (0)