diff --git a/tests/ContrastTest.php b/tests/ContrastTest.php index d8f8453..d361124 100644 --- a/tests/ContrastTest.php +++ b/tests/ContrastTest.php @@ -1,5 +1,6 @@ toRgba(), $b->toHsl())); })->with('contrast_colors'); + +it('calculates the luminance correctly for a white color', function () { + $white = Hex::fromString('#FFFFFF'); + $luminance = Contrast::calculateLuminance($white); + + expect($luminance)->toBe(1.0); +}); + +it('calculates the luminance correctly for a black color', function () { + $black = Hex::fromString('#000000'); + $luminance = Contrast::calculateLuminance($black); + + expect($luminance)->toBe(0.0); +}); diff --git a/tests/Datasets/Colors.php b/tests/Datasets/Colors.php index b1dd759..ae2d1c0 100644 --- a/tests/Datasets/Colors.php +++ b/tests/Datasets/Colors.php @@ -69,9 +69,9 @@ [Hex::fromString('#ffffff'), Hex::fromString('#ffffff'), 1.0], [Hex::fromString('#ffffff'), Hex::fromString('#000000'), 21.0], [Hex::fromString('#000000'), Hex::fromString('#000000'), 1.0], - [Hex::fromString('#faebd7'), Hex::fromString('#8a2be2'), 5.0], - [Hex::fromString('#ff1493'), Hex::fromString('#cd5c5c'), 1.0], - [Hex::fromString('#f0fff0'), Hex::fromString('#191970'), 15.0], + [Hex::fromString('#faebd7'), Hex::fromString('#8a2be2'), 5.16], + [Hex::fromString('#ff1493'), Hex::fromString('#cd5c5c'), 1.08], + [Hex::fromString('#f0fff0'), Hex::fromString('#191970'), 15.05], ]); dataset('hsla_string_and_rgb_values', function () {