import { describe, expect, it } from "vitest"; import { parseTestDocument, metaFieldValue } from "./testDocument"; import { splitTags } from "./tags"; const SUITE = [ "", "# opencode test @sprint_01", "", "Suite notes.", "", "", "## asdmalskdmn", "", "### Requirements", "", "### Steps", "", "* curl 'https://stable\\.testomat\\.io/api/runs?page=1' \\", " -H 'accept: application/json'", " *Expected result*: JSON comes back", "* Log in", "", "", "## Second @smoke", "", "```md", "## Not a heading", "\n## A\n### Steps\n* Go\n *Expected*: Done\n\n\n## B"); expect(test.steps[0].expected).toBe("Done"); expect(sections[1].steps[0].start).toBe(20); }); it("keeps text above the first comment as its own section", () => { const [intro, test] = parseTestDocument("Intro.\n\n\n# A"); expect(intro.meta).toBeNull(); expect([intro.start, intro.end]).toEqual([0, 2]); expect(test.heading?.text).toBe("A"); }); it("gives a file without comments one section", () => { expect(parseTestDocument("")).toEqual([]); expect(parseTestDocument("# Title")).toHaveLength(1); }); }); describe("splitTags", () => { it("pulls @tags out of a title", () => { expect(splitTags("Login works @smoke @severity:high")).toEqual({ title: "Login works", tags: ["@smoke", "@severity:high"], }); }); it("leaves emails alone", () => { expect(splitTags("Mail a@b.com")).toEqual({ title: "Mail a@b.com", tags: [] }); }); it("keeps a title made only of tags", () => { expect(splitTags("@smoke")).toEqual({ title: "@smoke", tags: ["@smoke"] }); }); });