From b13a5c829e16c8d94193dbfac7d3b0eb5434f828 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Tue, 8 Aug 2023 11:01:21 -0300 Subject: [PATCH] Add tests --- tests/src/Support/ColorTest.php | 79 +++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 tests/src/Support/ColorTest.php diff --git a/tests/src/Support/ColorTest.php b/tests/src/Support/ColorTest.php new file mode 100644 index 0000000000..4246de6900 --- /dev/null +++ b/tests/src/Support/ColorTest.php @@ -0,0 +1,79 @@ +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); +});