Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for No Columns defined - throws correct Exception #2057

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();

}
}
Loading