Skip to content

Commit

Permalink
Add tests for color helper
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusmoore committed Nov 8, 2023
1 parent 4382adc commit 49136a4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
12 changes: 8 additions & 4 deletions app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,14 @@ public static function formatCurrencyOutput($cost)
*
* @author [A. Gianotto] [<[email protected]>]
* @since [v3.3]
* @return array
* @return string
*/
public static function defaultChartColors($index = 0)
public static function defaultChartColors(int $index = 0)
{
if ($index < 0) {
$index = 0;
}

$colors = [
'#008941',
'#FF4A46',
Expand Down Expand Up @@ -359,8 +363,8 @@ public static function defaultChartColors($index = 0)
if($index < 0) {
$index = 0;
}
elseif($index > 265) {
$index = 265;
elseif($index >($total_colors - 1)) {
$index = $total_colors - 1;
}
}

Expand Down
21 changes: 0 additions & 21 deletions tests/Feature/DefaultColorKeyTest.php

This file was deleted.

19 changes: 19 additions & 0 deletions tests/Unit/Helpers/HelperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Tests\Unit\Helpers;

use App\Helpers\Helper;
use Tests\TestCase;

class HelperTest extends TestCase
{
public function testDefaultChartColorsMethodHandlesHighValues()
{
$this->assertIsString(Helper::defaultChartColors(1000));
}

public function testDefaultChartColorsMethodHandlesNegativeNumbers()
{
$this->assertIsString(Helper::defaultChartColors(-1));
}
}

0 comments on commit 49136a4

Please sign in to comment.