Skip to content

Commit 59a7967

Browse files
authored
Add ColorColumnTests (rappasoft#2074)
* Add ColorColumnTests * Fix styling --------- Co-authored-by: lrljoe <[email protected]>
1 parent 3036190 commit 59a7967

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/Unit/Views/Columns/ColorColumnTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,32 @@ function ($row) {
176176
$this->assertSame('#008000', $column->getColor($rows->slice(2, 1)->first()));
177177

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

0 commit comments

Comments
 (0)