import { parseIntroBlocks, splitLead } from "./introFormat"; test("splits paragraphs and bullet lists on blank lines", () => { const blocks = parseIntroBlocks( "Domanda: «X».\n\nEcco le famiglie:\n• uno → A\n• due → B\n\nConclusione." ); expect(blocks).toEqual([ { kind: "para", text: "Domanda: «X»." }, { kind: "para", text: "Ecco le famiglie:" }, { kind: "list", items: ["uno → A", "due → B"] }, { kind: "para", text: "Conclusione." }, ]); }); test("joins soft-wrapped paragraph lines into one flowing paragraph", () => { const blocks = parseIntroBlocks("prima riga\nseconda riga"); expect(blocks).toEqual([{ kind: "para", text: "prima riga seconda riga" }]); }); test("accepts -, * and • as bullet markers", () => { const blocks = parseIntroBlocks("- a\n* b\n• c"); expect(blocks).toEqual([{ kind: "list", items: ["a", "b", "c"] }]); }); test("bolds the lead term up to an arrow separator", () => { expect(splitLead("fact_impianto → IMPIANTO INIZIALE (dettaglio)")).toEqual({ lead: "fact_impianto", rest: " → IMPIANTO INIZIALE (dettaglio)", }); }); test("bolds the lead term up to a colon separator", () => { expect(splitLead("Nota: i controlli non sono impianto")).toEqual({ lead: "Nota", rest: ": i controlli non sono impianto", }); }); test("does not bold when there is no separator", () => { expect(splitLead("un punto elenco semplice")).toBeNull(); }); test("does not bold a long leading clause", () => { expect( splitLead("questa è una frase lunga con molte parole prima del: due punti") ).toBeNull(); });