|
2 | 2 |
|
3 | 3 | namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns; |
4 | 4 |
|
| 5 | +use Illuminate\Support\Facades\Blade; |
5 | 6 | use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; |
| 7 | +use Rappasoft\LaravelLivewireTables\Tests\Http\Components\TestComponent; |
6 | 8 | use Rappasoft\LaravelLivewireTables\Tests\Models\Pet; |
7 | 9 | use Rappasoft\LaravelLivewireTables\Tests\TestCase; |
8 | 10 | use Rappasoft\LaravelLivewireTables\Views\Column; |
9 | 11 | use Rappasoft\LaravelLivewireTables\Views\Columns\ComponentColumn; |
10 | | -use Rappasoft\LaravelLivewireTables\Tests\Http\Components\TestComponent; |
11 | | -use Illuminate\Support\Facades\Blade; |
12 | 12 |
|
13 | 13 | final class ComponentColumnTest extends TestCase |
14 | 14 | { |
@@ -42,50 +42,48 @@ public function test_can_not_be_both_collapsible_on_mobile_and_on_tablet(): void |
42 | 42 |
|
43 | 43 | } |
44 | 44 |
|
45 | | - |
46 | 45 | public function test_can_set_custom_slot(): void |
47 | 46 | { |
48 | 47 | $column = ComponentColumn::make('Age 2', 'age') |
49 | | - ->attributes(fn ($value, $row, Column $column) => [ |
50 | | - 'age' => $row->age, |
51 | | - ]) |
52 | | - ->slot(fn ($value, $row, Column $column) => [ |
53 | | - ($row->age < 2) => 'test1', |
54 | | - ($row->age > 2) => 'test2', |
55 | | - ]); |
| 48 | + ->attributes(fn ($value, $row, Column $column) => [ |
| 49 | + 'age' => $row->age, |
| 50 | + ]) |
| 51 | + ->slot(fn ($value, $row, Column $column) => [ |
| 52 | + ($row->age < 2) => 'test1', |
| 53 | + ($row->age > 2) => 'test2', |
| 54 | + ]); |
56 | 55 | $this->assertTrue($column->hasSlotCallback()); |
57 | 56 | } |
58 | 57 |
|
59 | | - |
60 | 58 | public function test_can_get_custom_slot(): void |
61 | 59 | { |
62 | 60 |
|
63 | 61 | $column = ComponentColumn::make('Age 2', 'age') |
64 | | - ->attributes(fn ($value, $row, Column $column) => [ |
65 | | - 'age' => $row->age, |
66 | | - ]) |
67 | | - ->slot(fn ($value, $row, Column $column) => (($row->age < 10) ? 'youngslot' : 'oldslot')) |
68 | | - ->component('livewire-tables-test::test'); |
| 62 | + ->attributes(fn ($value, $row, Column $column) => [ |
| 63 | + 'age' => $row->age, |
| 64 | + ]) |
| 65 | + ->slot(fn ($value, $row, Column $column) => (($row->age < 10) ? 'youngslot' : 'oldslot')) |
| 66 | + ->component('livewire-tables-test::test'); |
69 | 67 |
|
70 | 68 | $pet1 = Pet::where('age', '>', 11)->first(); |
71 | 69 | $pet1_contents = $column->getContents($pet1); |
72 | | - $this->assertSame('oldslot',$pet1_contents->getData()['slot']->__toString()); |
| 70 | + $this->assertSame('oldslot', $pet1_contents->getData()['slot']->__toString()); |
73 | 71 |
|
74 | 72 | $pet2 = Pet::where('age', '<', 5)->first(); |
75 | 73 | $pet2_contents = $column->getContents($pet2); |
76 | | - $this->assertSame('youngslot',$pet2_contents->getData()['slot']->__toString()); |
| 74 | + $this->assertSame('youngslot', $pet2_contents->getData()['slot']->__toString()); |
77 | 75 |
|
78 | 76 | } |
79 | 77 |
|
80 | 78 | public function test_can_get_attributes(): void |
81 | 79 | { |
82 | 80 |
|
83 | 81 | $column = ComponentColumn::make('Age 2', 'age') |
84 | | - ->attributes(fn ($value, $row, Column $column) => [ |
85 | | - 'age' => $row->age, |
86 | | - ]) |
87 | | - ->slot(fn ($value, $row, Column $column) => (($row->age < 10) ? 'youngslot' : 'oldslot')) |
88 | | - ->component('livewire-tables-test::test'); |
| 82 | + ->attributes(fn ($value, $row, Column $column) => [ |
| 83 | + 'age' => $row->age, |
| 84 | + ]) |
| 85 | + ->slot(fn ($value, $row, Column $column) => (($row->age < 10) ? 'youngslot' : 'oldslot')) |
| 86 | + ->component('livewire-tables-test::test'); |
89 | 87 |
|
90 | 88 | $pet1 = Pet::where('age', '>', 11)->first(); |
91 | 89 | $pet1_contents = $column->getContents($pet1); |
|
0 commit comments