mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 17:27:28 +00:00
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { markdownToMatrixHtml } from "./format.js";
|
|
|
|
describe("markdownToMatrixHtml", () => {
|
|
it("renders basic inline formatting", () => {
|
|
const html = markdownToMatrixHtml("hi _there_ **boss** `code`");
|
|
expect(html).toContain("<em>there</em>");
|
|
expect(html).toContain("<strong>boss</strong>");
|
|
expect(html).toContain("<code>code</code>");
|
|
});
|
|
|
|
it("renders links as HTML", () => {
|
|
const html = markdownToMatrixHtml("see [docs](https://example.com)");
|
|
expect(html).toContain('<a href="https://example.com">docs</a>');
|
|
});
|
|
|
|
it("escapes raw HTML", () => {
|
|
const html = markdownToMatrixHtml("<b>nope</b>");
|
|
expect(html).toContain("<b>nope</b>");
|
|
expect(html).not.toContain("<b>nope</b>");
|
|
});
|
|
|
|
it("flattens images into alt text", () => {
|
|
const html = markdownToMatrixHtml("");
|
|
expect(html).toContain("alt");
|
|
expect(html).not.toContain("<img");
|
|
});
|
|
|
|
it("preserves line breaks", () => {
|
|
const html = markdownToMatrixHtml("line1\nline2");
|
|
expect(html).toContain("<br");
|
|
});
|
|
});
|