import {
  getColorContrast,
  getYIQ,
  getContrastYIQ,
  renderContrastColor,
} from "../contrast";

describe("contrast", () => {
  const theme = {
    RED: "#ff0000",
    GREEN: "#00ff00",
    BLUE: "#0000ff",
    YELLOW: "#ffff00",
  };

  it("retrieves functions that accept the theme", () => {
    expect(typeof renderContrastColor()).toBe("function");
  });

  it("getColorContrast", () => {
    expect(getColorContrast("red", "green")).toBe(1.29);
    expect(getColorContrast("green", "red")).toBe(1.29);
  });

  it("getYIQ", () => {
    expect(getYIQ("red")).toBe(76.245);
    expect(getYIQ("green")).toBe(75.136);
    expect(getYIQ("blue")).toBe(29.07);
  });

  it("getContrastYIQ", () => {
    expect(getContrastYIQ("black")).toBe("#fff");
    expect(getContrastYIQ("white")).toBe("#212529");
    expect(getContrastYIQ("black", "red", "yellow")).toBe("yellow");
    expect(getContrastYIQ("white", "red", "yellow")).toBe("red");
    expect(getContrastYIQ("yellow", "red", "yellow", "blue")).toBe("blue");
  });

  it("renderContrastColor", () => {
    expect(
      renderContrastColor("RED", "GREEN", "BLUE", "YELLOW")({ theme }),
    ).toBe("#ffff00");
  });
});
