import { isTransparentColor } from ".."; describe("isTransparentColor", () => { it("returns true for transparent keyword and rgba colors with zero alpha", () => { const transparentColors = [ "transparent", "rgba(0,0,0,0)", "rgba(255, 255, 255, 0)", "rgba(0,0,0,0.0)", "rgba(0,0,0,0.00)", "rgba(0,0,0, 0)", "hsla(0,0%,0%,0)", ]; expect.assertions(transparentColors.length); transparentColors.forEach((color) => { expect(isTransparentColor(color)).toBe(true); }); }); it("returns false for valid colors that are not fully transparent", () => { const nonTransparentColors = [ "red", "#fff", "#ffffff", "rgb(0,0,0)", "rgba(0,0,0)", "rgba(0,0,0,0.5)", "rgba(255, 255, 255, 0.3)", "rgba(255, 255, 255, 1.0)", "rgba(239,239,239,1.0)", "currentColor", "inherit", "#00000000", "#fff0", ]; expect.assertions(nonTransparentColors.length); nonTransparentColors.forEach((color) => { expect(isTransparentColor(color)).toBe(false); }); }); it("returns false for case variants of the transparent keyword", () => { expect(isTransparentColor("Transparent")).toBe(false); expect(isTransparentColor("TRANSPARENT")).toBe(false); }); it("returns false for invalid color strings", () => { const invalidColors = [ "invalid", "", "#gggggg", "#fff.00", "unset", " rgba(0,0,0,0) ", "transparent ", ]; expect.assertions(invalidColors.length); invalidColors.forEach((color) => { expect(isTransparentColor(color)).toBe(false); }); }); it("returns false for nullish and non-string values", () => { expect(isTransparentColor(undefined)).toBe(false); expect(isTransparentColor(null)).toBe(false); expect(isTransparentColor(123)).toBe(false); expect(isTransparentColor({})).toBe(false); expect(isTransparentColor([])).toBe(false); }); });