import { describe, expect, it } from "vitest";
import {
  DEFAULT_SIGNUP_BILLING_INTENT,
  isSignupBillingIntent,
  satisfiesPendingCheckoutPlan,
} from "./billing";

describe("billing helpers", () => {
  it("defaults signup intent to solo", () => {
    expect(DEFAULT_SIGNUP_BILLING_INTENT).toBe("solo");
  });

  it("recognizes only solo, team and founder as signup intents", () => {
    expect(isSignupBillingIntent("solo")).toBe(true);
    expect(isSignupBillingIntent("team")).toBe(true);
    expect(isSignupBillingIntent("founder")).toBe(true);
    expect(isSignupBillingIntent("trial")).toBe(false);
  });

  it("computes checkout satisfaction against active subscription plan", () => {
    expect(satisfiesPendingCheckoutPlan("founder", "annual")).toBe(true);
    expect(satisfiesPendingCheckoutPlan("founder", "team")).toBe(false);
    expect(satisfiesPendingCheckoutPlan("team", "team")).toBe(true);
    expect(satisfiesPendingCheckoutPlan("team", "annual")).toBe(true);
    expect(satisfiesPendingCheckoutPlan("solo", "solo")).toBe(true);
    expect(satisfiesPendingCheckoutPlan("solo", "team")).toBe(true);
    expect(satisfiesPendingCheckoutPlan("solo", "annual")).toBe(true);
    expect(satisfiesPendingCheckoutPlan("solo", null)).toBe(false);
  });
});
