import { camelcaseify, StringUtils } from "./string.utils";

const { decodify, ensureValidIdFormat } = StringUtils;

jest.mock("./color.utils", () => {
  const originalModule = jest.requireActual("./color.utils");

  //Mock the default export and named export 'foo'
  return {
    __esModule: true,
    ...originalModule,
    // default: jest.fn(() => "mocked setAlpha"),
    setAlpha: () => "rgba(0,0,0,1)",
    fromColorStringToRgbaObject: () => ({ r: 0, g: 0, b: 0, a: 0 }),
    getStringRgbaColor: () => "rgba(0,0,0,1)",
  };
});
describe("string.utils", () => {
  test("decodify", () => {
    let dStr = decodify("super-light-blue");
    expect(dStr).toEqual("Super light blue");

    dStr = decodify("super_light-blue");
    expect(dStr).toEqual("Super light blue");

    dStr = decodify("super...light.blue");
    expect(dStr).toEqual("Super light blue");
  });

  test("camelcaseify", () => {
    let cStr = camelcaseify("super-light-blue");
    expect(cStr).toEqual("superLightBlue");
  });

  test("ensureValidIdFormat", () => {
    let cStr = ensureValidIdFormat("super light blue");
    expect(cStr).toEqual("superLightBlue");
  });

  test("clean", () => {
    const str = StringUtils.clean(":hover");
    expect(str).toEqual("Hover");

    const str2 = StringUtils.clean(":focus-within");
    expect(str2).toEqual("Focus Within");
  });
});
