Skip to content

Commit 03c7796

Browse files
authored
Add test for No Columns defined - throws correct Exception (rappasoft#2057)
* Add test for No Columns * Fix styling --------- Co-authored-by: lrljoe <[email protected]>
1 parent 4aa03fa commit 03c7796

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/Unit/Traits/Helpers/ColumnHelpersTest.php

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

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

5+
use Rappasoft\LaravelLivewireTables\Exceptions\NoColumnsException;
6+
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
57
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
68
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
79
use Rappasoft\LaravelLivewireTables\Views\Column;
@@ -360,4 +362,27 @@ 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+
}
363388
}

0 commit comments

Comments
 (0)