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

import {
  CheckoutHandoffConsumeResponseSchema,
  CheckoutHandoffCreateRequestSchema,
} from "../checkout_handoff";

describe("checkout handoff schemas", () => {
  it("keeps only the minimal order-free purchase intent", () => {
    expect(
      CheckoutHandoffCreateRequestSchema.parse({
        planId: "vip_monthly",
        autoRenew: true,
        recipientCharacterId: "elio",
        price: 9.99,
      }),
    ).toEqual({
      planId: "vip_monthly",
      autoRenew: true,
      recipientCharacterId: "elio",
    });
  });

  it("parses the formal session and checkout intent returned after consumption", () => {
    const parsed = CheckoutHandoffConsumeResponseSchema.parse({
      user: {
        id: "00000000-0000-0000-0000-000000000123",
        username: "checkout-user",
        email: "checkout@example.com",
        platform: "web",
      },
      token: "access-token",
      refreshToken: "refresh-token",
      loginStatus: "email",
      checkoutIntent: {
        planId: "vip_monthly",
        autoRenew: true,
      },
    });

    expect(parsed.checkoutIntent.planId).toBe("vip_monthly");
    expect(parsed.loginStatus).toBe("email");
  });
});
