import { describe, expect, it } from "vitest"; import messages from "../../messages/en/index"; import { collectHowItWorksGuideText, formatHowItWorksByline, formatHowItWorksDate, howItWorksReadMinutes, howItWorksWikiMarkdown, } from "../../lib/howItWorksGuide"; describe("howItWorksGuide", () => { const page = messages.pages.howItWorks; it("formats the Figma date and byline from the final text", () => { expect(formatHowItWorksDate(page.banner.date)).toBe("18 February 2027"); const minutes = howItWorksReadMinutes(page); expect(minutes).toBeGreaterThanOrEqual(10); expect(formatHowItWorksByline(page, minutes)).toBe( `By CommunityRule Creative Team. 18 February 2027. ${minutes} minute read. `, ); expect(collectHowItWorksGuideText(page)).toContain( "A Rule is a short document your community can read aloud in a few minutes.", ); expect(collectHowItWorksGuideText(page)).not.toContain("](/kit)"); }); it("builds wiki markdown from the title, description and URL", () => { expect( howItWorksWikiMarkdown( page.banner.title, page.banner.description, "https://communityrule.info/how-it-works", ), ).toBe( `[${page.banner.title}](https://communityrule.info/how-it-works)\n\n${page.banner.description}`, ); }); });