import { describe, expect, it } from "vitest";

import {
  buildTipCoffeePath,
  getTipCoffeeOption,
  resolveTipCoffeeType,
} from "../tip_coffee";

describe("tip coffee configuration", () => {
  it("resolves supported types case-insensitively", () => {
    expect(resolveTipCoffeeType(" Small ")).toBe("small");
    expect(resolveTipCoffeeType("MEDIUM")).toBe("medium");
    expect(resolveTipCoffeeType("large")).toBe("large");
  });

  it("rejects missing and unsupported types", () => {
    expect(resolveTipCoffeeType(null)).toBeNull();
    expect(resolveTipCoffeeType("espresso")).toBeNull();
  });

  it("provides the configured plan and fallback price for each type", () => {
    expect(getTipCoffeeOption("small")).toMatchObject({
      amountCents: 499,
      planId: "tip_coffee_usd_4_99",
    });
    expect(getTipCoffeeOption("medium")).toMatchObject({
      amountCents: 999,
      planId: "tip_coffee_usd_9_99",
    });
    expect(getTipCoffeeOption("large")).toMatchObject({
      amountCents: 1999,
      planId: "tip_coffee_usd_19_99",
    });
  });

  it("builds canonical tip paths", () => {
    expect(buildTipCoffeePath("small")).toBe("/tip?coffee_type=small");
    expect(buildTipCoffeePath("medium")).toBe("/tip?coffee_type=medium");
    expect(buildTipCoffeePath("large")).toBe("/tip?coffee_type=large");
  });
});
