import { describe, expect, it } from "vitest";
import { getTintedCardSurfaceStyles } from "./shop-info.color.utils";

describe("shop info color utilities", () => {
  it("scales card tint intensity with alpha for plain rgba values", () => {
    expect(
      getTintedCardSurfaceStyles({
        r: 22,
        g: 119,
        b: 255,
        a: 0.5
      })
    ).toEqual({
      surfaceBg: "color-mix(in srgb, rgb(22, 119, 255) 5%, var(--imex-form-surface))",
      surfaceHeaderBg: "color-mix(in srgb, rgb(22, 119, 255) 9%, var(--imex-form-surface-head))",
      surfaceBorderColor: "color-mix(in srgb, rgb(22, 119, 255) 15%, var(--imex-form-surface-border))"
    });
  });

  it("returns no tint when the selected color alpha is zero", () => {
    expect(
      getTintedCardSurfaceStyles({
        hex: "#1677ff",
        rgb: {
          r: 22,
          g: 119,
          b: 255,
          a: 0
        }
      })
    ).toEqual({});
  });

  it("supports legacy JSON-stringified picker values", () => {
    expect(
      getTintedCardSurfaceStyles(
        JSON.stringify({
          rgb: {
            r: 255,
            g: 0,
            b: 0,
            a: 0.25
          }
        })
      )
    ).toEqual({
      surfaceBg: "color-mix(in srgb, rgb(255, 0, 0) 2.5%, var(--imex-form-surface))",
      surfaceHeaderBg: "color-mix(in srgb, rgb(255, 0, 0) 4.5%, var(--imex-form-surface-head))",
      surfaceBorderColor: "color-mix(in srgb, rgb(255, 0, 0) 7.5%, var(--imex-form-surface-border))"
    });
  });
});
