import { describe, expect, it } from "vitest"; import { membershipInvitePreview } from "../../lib/create/membershipInvitePreview"; import type { CreateFlowState } from "../../app/(app)/create/types"; describe("membershipInvitePreview", () => { it("returns null when no membership method is selected", () => { expect(membershipInvitePreview({} as CreateFlowState)).toBeNull(); }); it("uses the first selected membership method and saved words", () => { const preview = membershipInvitePreview({ selectedMembershipMethodIds: ["open-admission"], membershipMethodDetailsById: { "open-admission": { eligibility: "Anyone who shares the work belongs.", joiningProcess: "Work two Sunday shares, then ask to join.", expectations: "", }, }, } as CreateFlowState); expect(preview?.title).toBe("Open admission"); expect(preview?.categoryName).toBe("Membership"); expect(preview?.eligibility).toBe("Anyone who shares the work belongs."); expect(preview?.joiningProcess).toBe( "Work two Sunday shares, then ask to join.", ); }); });