diff --git a/tests/markdown.test.ts b/tests/markdown.test.ts new file mode 100644 index 0000000..21a2404 --- /dev/null +++ b/tests/markdown.test.ts @@ -0,0 +1,32 @@ +import { renderSupplierText } from "../web/src/markdown.ts"; + +function assert(condition: unknown, message: string): asserts condition { + if (!condition) { + throw new Error(message); + } +} + +Deno.test("plain supplier text with markdown links becomes clickable, and safe", () => { + // #295: Harderwijk's agenda text, as iBabs delivers it. + const html = renderSupplierText( + "De vergadering is te volgen via [www.harderwijk.nl/vergaderingen](https://www.harderwijk.nl/vergaderingen). \n \nProces: is geen markup.", + ); + assert( + html.includes( + 'www.harderwijk.nl/vergaderingen', + ), + `the markdown link is rendered, got ${html}`, + ); + assert(!html.includes(" ") && !html.includes("\r"), "carriage-return entities are dropped"); + assert(!html.includes("