Testing Color Lightness Utility Function in Bourbon
This test suite validates the lightness utility function in Bourbon, which calculates the lightness value of colors. The tests verify that the function correctly outputs normalized values between 0 and 1 for different color inputs, ensuring accurate color processing capabilities.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
thoughtbot/bourbon
spec/bourbon/utilities/lightness_spec.rb
require "spec_helper"
describe "lightness" do
before(:all) do
ParserSupport.parse_file("utilities/lightness")
end
context "called on black" do
it "outputs a number between 0 and 1 to indicate lightness" do
rule = "content: 0;"
expect(".lightness-black").to have_ruleset(rule)
end
end
context "called on white" do
it "outputs a number between 0 and 1 to indicate lightness" do
rule = "content: 1;"
expect(".lightness-white").to have_ruleset(rule)
end
end
context "called on gray" do
it "outputs a number between 0 and 1 to indicate lightness" do
rule = "content: 0.20503;"
expect(".lightness-gray").to have_ruleset(rule)
end
end
end