import { describe, expect, it } from "vitest"; import { atomsToText, formatDateAtom, parseInlineAtoms, STATUS_COLORS, STATUS_VALUES } from "./inline-atoms.js"; describe("inline atoms (T-148)", () => { it("parses date/status/label tokens", () => { const segs = parseInlineAtoms("Due @date(2026-10-11) and @status(done) for @label(Q3)"); expect(segs).toEqual([ { type: "text", text: "Due " }, { type: "atom", kind: "date", value: "2026-10-11" }, { type: "text", text: " and " }, { type: "atom", kind: "status", value: "done" }, { type: "text", text: " for " }, { type: "atom", kind: "label", value: "Q3" } ]); }); it("passes plain text through unchanged (legacy docs)", () => { expect(parseInlineAtoms("no atoms here")).toEqual([{ type: "text", text: "no atoms here" }]); expect(parseInlineAtoms("")).toEqual([]); }); it("rejects malformed dates / unknown status values (kept as literal text)", () => { expect(parseInlineAtoms("bad @date(2026-13-99) @status(maybe)")).toEqual([ { type: "text", text: "bad @date(2026-13-99) @status(maybe)" } ]); // @mention-style tokens are NOT atoms → literal expect(parseInlineAtoms("hi @alice")).toEqual([{ type: "text", text: "hi @alice" }]); }); it("round-trips through atomsToText", () => { const original = "a @status(to-do) b @date(2026-01-01) c @label(x y) d"; expect(atomsToText(parseInlineAtoms(original))).toBe(original); }); it("exposes the status palette", () => { for (const s of STATUS_VALUES) expect(typeof STATUS_COLORS[s]).toBe("string"); expect(STATUS_COLORS["blocked"]).toBe("red"); expect(STATUS_COLORS["done"]).toBe("green"); }); it("formatDateAtom is a no-op for invalid ISO", () => { expect(formatDateAtom("2026-10-11")).toBe("2026-10-11"); }); });