Skip to content

Commit

Permalink
Visual addition in Boolean component (#2838)
Browse files Browse the repository at this point in the history
* Make some pretty space in Boolean component

* BooleanTest Unit Test Update
  • Loading branch information
ega22a authored May 31, 2024
1 parent 52854bb commit a0a02e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Screen/Components/Cells/Boolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(?bool $value, ?string $true = null, ?string $false =
*/
public function render()
{
$class = $this->value ? 'text-success' : 'text-danger';
$class = 'me-1 '.($this->value ? 'text-success' : 'text-danger');
$label = $this->value ? $this->true : $this->false;

return "<span class='$class'>●</span>".$label;
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/Cells/BooleanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ public function testRenderBooleanComponent(): void
{
$component = new Boolean(true);

$this->assertEquals("<span class='text-success'>●</span>", $component->render());
$this->assertEquals("<span class='me-1 text-success'>●</span>", $component->render());

$component = new Boolean(false);

$this->assertEquals("<span class='text-danger'>●</span>", $component->render());
$this->assertEquals("<span class='me-1 text-danger'>●</span>", $component->render());
}

public function testRenderBooleanWithNullComponent(): void
{
$component = new Boolean(null);

$this->assertEquals("<span class='text-danger'>●</span>", $component->render());
$this->assertEquals("<span class='me-1 text-danger'>●</span>", $component->render());
}

public function testRenderBooleanWithLabelComponent(): void
{
$component = new Boolean(true, true: 'Enabled', false: 'Disabled');

$this->assertEquals("<span class='text-success'>●</span>Enabled", $component->render());
$this->assertEquals("<span class='me-1 text-success'>●</span>Enabled", $component->render());

$component = new Boolean(false, true: 'Enabled', false: 'Disabled');

$this->assertEquals("<span class='text-danger'>●</span>Disabled", $component->render());
$this->assertEquals("<span class='me-1 text-danger'>●</span>Disabled", $component->render());
}
}

0 comments on commit a0a02e7

Please sign in to comment.