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

import { shouldInspectPendingPaymentOrder } from "../use-pending-payment-order-lifecycle";

describe("shouldInspectPendingPaymentOrder", () => {
  it("allows pending order inspection when payment plans are ready", () => {
    expect(
      shouldInspectPendingPaymentOrder({
        currentOrderId: null,
        isPaid: false,
        isPollingOrder: false,
        shouldResumePendingOrder: true,
        status: "ready",
      }),
    ).toBe(true);
  });

  it("allows cleanup inspection for active stale payment state", () => {
    expect(
      shouldInspectPendingPaymentOrder({
        currentOrderId: "order-1",
        isPaid: false,
        isPollingOrder: true,
        shouldResumePendingOrder: false,
        status: "pollingOrder",
      }),
    ).toBe(true);
  });

  it("waits when resume is requested but payment plans are not ready", () => {
    expect(
      shouldInspectPendingPaymentOrder({
        currentOrderId: "order-1",
        isPaid: false,
        isPollingOrder: true,
        shouldResumePendingOrder: true,
        status: "pollingOrder",
      }),
    ).toBe(false);
  });

  it("allows stale expired orders to be cleaned up", () => {
    expect(
      shouldInspectPendingPaymentOrder({
        currentOrderId: "order-expired",
        isPaid: false,
        isPollingOrder: false,
        shouldResumePendingOrder: false,
        status: "expired",
      }),
    ).toBe(true);
  });
});
