Skip to content

Commit

Permalink
Add test for No Columns defined - throws correct Exception (#2057)
Browse files Browse the repository at this point in the history
* Add test for No Columns

* Fix styling

---------

Co-authored-by: lrljoe <lrljoe@users.noreply.github.com>
  • Loading branch information
lrljoe and lrljoe authored Nov 12, 2024
1 parent 4aa03fa commit 03c7796
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/Unit/Traits/Helpers/ColumnHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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

use Rappasoft\LaravelLivewireTables\Exceptions\NoColumnsException;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Column;
Expand Down Expand Up @@ -360,4 +362,27 @@ public function test_can_check_if_column_label_has_attributes(): void
$this->assertSame(['class' => 'text-xl', 'default' => true, 'default-colors' => false, 'default-styling' => false], $column->getLabelAttributes());

}

public function test_throws_error_if_no_columns_are_defined(): void
{
$this->expectException(NoColumnsException::class);

$testTable = new class extends PetsTable
{
public function columns(): array
{
return [];
}
};

$testTable->configure();
$testTable->boot();
$testTable->bootedComponentUtilities();
$testTable->bootedWithData();
$testTable->bootedWithColumns();
$testTable->bootedWithColumnSelect();
$testTable->bootedWithSecondaryHeader();
$testTable->booted();

}
}

0 comments on commit 03c7796

Please sign in to comment.