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

import { buildPendingPaymentSubscriptionUrl } from "../pending_payment_order";

describe("pending payment order helpers", () => {
  it("keeps the pay channel when rebuilding subscription return urls", () => {
    expect(
      buildPendingPaymentSubscriptionUrl({
        payChannel: "ezpay",
        returnTo: "chat",
        subscriptionType: "topup",
      }),
    ).toBe("/subscription?type=topup&payChannel=ezpay&paymentReturn=1&returnTo=chat");
  });

  it("routes tip payments back to the tip page", () => {
    expect(
      buildPendingPaymentSubscriptionUrl({
        payChannel: "ezpay",
        subscriptionType: "tip",
        tipCoffeeType: "large",
      }),
    ).toBe("/tip?payChannel=ezpay&paymentReturn=1&coffee_type=large");
  });

  it("defaults legacy tip payment returns to small coffee", () => {
    expect(
      buildPendingPaymentSubscriptionUrl({
        payChannel: "ezpay",
        subscriptionType: "tip",
      }),
    ).toBe("/tip?payChannel=ezpay&paymentReturn=1&coffee_type=small");
  });
});
