Skip to content

Commit

Permalink
Add Initial Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lrljoe authored Nov 1, 2024
1 parent d7bb75f commit 45e2ccc
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/Traits/Visuals/Columns/IncrementColumnVisualsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Tests\Traits\Visuals\Columns;

use Exception;
use Illuminate\View\ViewException;
use Livewire\Livewire;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\FailingTables\{BrokenSecondaryHeaderTable, NoBuildMethodTable, NoPrimaryKeyTable};
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\{PetsTable,PetsTableAttributes};
use Rappasoft\LaravelLivewireTables\Tests\TestCase;

final class IncrementColumnVisualsTest extends TestCase
{
private $testErrors;

/*
public function test_increment_column_renders_correctly(): void
{
Livewire::test(new class extends PetsTable
{
public function configure(): void
{
$this->setPrimaryKey('id');
}
public function columns(): array
{
return [
\Rappasoft\LaravelLivewireTables\Views\Columns\IncrementColumn::make('#'),
\Rappasoft\LaravelLivewireTables\Views\Column::make('Name')->searchable(),
];
}
public function filters(): array
{
return [];
}
})
->assertSeeHtmlInOrder([
'<tr rowpk="1"',
'<td',
'<div>1</div>',
]);
}*/
}
40 changes: 40 additions & 0 deletions tests/Views/Columns/IncrementColumnTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Tests\Views\Columns;

use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Columns\IncrementColumn;

final class IncrementColumnTest extends TestCase
{
public function test_can_set_the_column_title(): void
{
$column = IncrementColumn::make('Name', 'name');

$this->assertSame('Name', $column->getTitle());
}

public function test_can_not_infer_field_name_from_title_if_no_from(): void
{
$column = IncrementColumn::make('My Title');

$this->assertNull($column->getField());
}

public function test_can_not_render_field_if_no_title(): void
{
$this->expectException(\ArgumentCountError::class);

IncrementColumn::make()->getContents(Pet::find(1));
}

public function test_renders_correctly(): void
{
$rows = $this->basicTable->getRows();
$row1 = $rows->first();

}

}

0 comments on commit 45e2ccc

Please sign in to comment.