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

import {
  buildTipGiftPath,
  normalizeTipGiftParam,
} from "../tip_gift";

describe("tip gift navigation", () => {
  it("normalizes optional gift query values", () => {
    expect(normalizeTipGiftParam(" coffee ")).toBe("coffee");
    expect(normalizeTipGiftParam("  ")).toBeNull();
    expect(normalizeTipGiftParam(null)).toBeNull();
  });

  it("builds canonical category and plan return paths", () => {
    expect(
      buildTipGiftPath({ category: "coffee", planId: "gift_1" }),
    ).toBe("/tip?category=coffee&planId=gift_1");
  });

  it("omits missing selection values without restoring coffee_type", () => {
    expect(buildTipGiftPath({ category: null, planId: null })).toBe("/tip");
  });
});
