UNPKG

@applicaster/zapp-react-native-utils

Version:

Applicaster Zapp React Native utilities package

63 lines (44 loc) 1.51 kB
import { transformColorCode } from "../"; describe("transformColorCode", () => { it("fixes the color code", () => { expect(transformColorCode("#AA000000")).toBe("#000000AA"); }); it("should transform alpha channel to the end", () => { const colorHex = "#AARRGGBB"; const expected = "#RRGGBBAA"; const result = transformColorCode(colorHex); expect(result).toEqual(expected); }); it("fixes the color code", () => { expect(transformColorCode("rgba(0,18,63,0.25)")).toEqual( "rgba(0,18,63,0.25)" ); }); it("fixes the color code", () => { expect(transformColorCode(undefined)).toBeUndefined(); }); it("should not transform six digit colors", () => { const colorHex = "#RRGGBB"; const expected = "#RRGGBB"; const result = transformColorCode(colorHex); expect(result).toEqual(expected); }); it("should not transform named color ", () => { const colorHex = "red"; const expected = "red"; const result = transformColorCode(colorHex); expect(result).toEqual(expected); }); it("should not transform 3 digit colors #FD0 ", () => { const colorHex = "#FD0"; const expected = "#FD0"; const result = transformColorCode(colorHex); expect(result).toEqual(expected); }); it("should return undefined when input is undefined", () => { const colorHex = undefined; const expected = undefined; const result = transformColorCode(colorHex); expect(result).toBe(expected); }); });