Skip to content

Commit eeff29d

Browse files
committed
Add ColorColumnTests
1 parent 3036190 commit eeff29d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/Unit/Views/Columns/ColorColumnTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function test_can_get_the_column_view(): void
2424

2525
}
2626

27+
2728
public function test_can_infer_field_name_from_title_if_no_from(): void
2829
{
2930
$column = ColorColumn::make('Favorite Color');
@@ -176,4 +177,32 @@ function ($row) {
176177
$this->assertSame('#008000', $column->getColor($rows->slice(2, 1)->first()));
177178

178179
}
180+
181+
public function test_can_get_column_get_contents_from_color(): void
182+
{
183+
$column = ColorColumn::make('Species Color')->color(
184+
function ($row) {
185+
if ($row->species_id == 1) {
186+
return '#ff0000';
187+
} elseif ($row->species_id == 2) {
188+
return '#008000';
189+
} else {
190+
return '#ffa500';
191+
}
192+
193+
}
194+
);
195+
$rows = $this->basicTable->setAdditionalSelects(['pets.species_id as species_id'])->getRows();
196+
197+
$contents1 = $column->getContents($rows->first());
198+
$this->assertSame($contents1['color'], '#ff0000');
199+
$this->assertSame($contents1['isTailwind'], true);
200+
$this->assertSame($contents1['isBootstrap'], false);
201+
202+
$contents2 = $column->getContents($rows->last());
203+
$this->assertSame($contents2['color'], '#ffa500');
204+
$this->assertSame($contents2['isTailwind'], true);
205+
$this->assertSame($contents2['isBootstrap'], false);
206+
207+
}
179208
}

0 commit comments

Comments
 (0)