Add tests

This commit is contained in:
Kennedy Tedesco
2023-08-08 11:01:21 -03:00
parent e069570d77
commit b13a5c829e
+79
View File
@@ -0,0 +1,79 @@
<?php
use Filament\Support\Colors\Color;
use Filament\Tests\TestCase;
uses(TestCase::class);
test('get color from hex', function () {
expect(Color::hex('#49D359'))
->toBe([
50 => '246, 253, 247',
100 => '237, 251, 238',
200 => '210, 244, 214',
300 => '182, 237, 189',
400 => '128, 224, 139',
500 => '73, 211, 89',
600 => '66, 190, 80',
700 => '55, 158, 67',
800 => '44, 127, 53',
900 => '36, 103, 44',
950 => '22, 63, 27',
])
->and(Color::hex('#FF0000'))
->toBe([
50 => '255, 242, 242',
100 => '255, 230, 230',
200 => '255, 191, 191',
300 => '255, 153, 153',
400 => '255, 77, 77',
500 => '255, 0, 0',
600 => '230, 0, 0',
700 => '191, 0, 0',
800 => '153, 0, 0',
900 => '125, 0, 0',
950 => '77, 0, 0',
]);
});
test('get color from rgb', function () {
expect(Color::rgb('rgb(73, 211, 89)'))
->toBe([
50 => '246, 253, 247',
100 => '237, 251, 238',
200 => '210, 244, 214',
300 => '182, 237, 189',
400 => '128, 224, 139',
500 => '73, 211, 89',
600 => '66, 190, 80',
700 => '55, 158, 67',
800 => '44, 127, 53',
900 => '36, 103, 44',
950 => '22, 63, 27',
])
->and(Color::rgb('rgb(255, 0, 0)'))
->toBe([
50 => '255, 242, 242',
100 => '255, 230, 230',
200 => '255, 191, 191',
300 => '255, 153, 153',
400 => '255, 77, 77',
500 => '255, 0, 0',
600 => '230, 0, 0',
700 => '191, 0, 0',
800 => '153, 0, 0',
900 => '125, 0, 0',
950 => '77, 0, 0',
]);
});
test('get colors', function () {
$colors = [];
foreach ((new ReflectionClass(Color::class))->getConstants() as $name => $color) {
$colors[strtolower($name)] = $color;
}
expect(Color::colors())
->toBe($colors);
});