import { describe, expect, it } from "vitest"; import { GROWTH_PLAN, LOCATION_LIMITS, locationLimitFor, PRO_PLAN, STARTER_PLAN, tierAtLeast, tierFromPlanName, } from "../../app/lib/billing-plans"; describe("tierAtLeast", () => { it("orders tiers free < starter < growth < pro", () => { expect(tierAtLeast("free", "free")).toBe(true); expect(tierAtLeast("free", "starter")).toBe(false); expect(tierAtLeast("starter", "free")).toBe(true); expect(tierAtLeast("growth", "starter")).toBe(true); expect(tierAtLeast("starter", "growth")).toBe(false); expect(tierAtLeast("pro", "growth")).toBe(true); }); }); describe("locationLimitFor", () => { it("caps Free at 1 and Starter at 3, per PRODUCT_STRATEGY.md ยง6", () => { expect(locationLimitFor("free")).toBe(1); expect(locationLimitFor("starter")).toBe(3); }); it("has no limit (null) for Growth and Pro", () => { expect(locationLimitFor("growth")).toBeNull(); expect(locationLimitFor("pro")).toBeNull(); }); it("matches the exported LOCATION_LIMITS table", () => { expect(locationLimitFor("free")).toBe(LOCATION_LIMITS.free); }); }); describe("tierFromPlanName", () => { it("maps each configured plan name back to its tier", () => { expect(tierFromPlanName(STARTER_PLAN)).toBe("starter"); expect(tierFromPlanName(GROWTH_PLAN)).toBe("growth"); expect(tierFromPlanName(PRO_PLAN)).toBe("pro"); }); it("falls back to free for an unrecognized or missing plan name", () => { expect(tierFromPlanName("Some Other Plan")).toBe("free"); expect(tierFromPlanName(undefined)).toBe("free"); expect(tierFromPlanName(null)).toBe("free"); }); });