feat(f7.1): sequence-diagram parser (#22)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ben Stull
2026-06-11 16:31:44 -07:00
parent 1454c7792a
commit 96931f245d
2 changed files with 84 additions and 1 deletions
+24
View File
@@ -0,0 +1,24 @@
import { describe, it, expect } from "vitest";
import { parseSequence } from "../src/mermaidSequenceDiff";
describe("parseSequence", () => {
it("captures explicit participants in order", () => {
const d = parseSequence("sequenceDiagram\n participant A\n participant B\n A->>B: hi");
expect(d.participants).toEqual(["A", "B"]);
});
it("captures message statements verbatim (trimmed)", () => {
const d = parseSequence("sequenceDiagram\n A->>B: hi\n B-->>A: bye");
expect(d.statements).toEqual(["A->>B: hi", "B-->>A: bye"]);
});
it("infers participants from messages when not declared", () => {
const d = parseSequence("sequenceDiagram\n A->>B: hi\n B->>C: on");
expect(d.participants).toEqual(["A", "B", "C"]);
});
it("ignores comments and blank lines", () => {
const d = parseSequence("sequenceDiagram\n%% note\n\n A->>B: hi");
expect(d.statements).toEqual(["A->>B: hi"]);
});
});