mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-08-23 20:07:04 +00:00
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { renderMessageMarkdown } from "./renderMessageMarkdown";
|
|
|
|
describe("renderMessageMarkdown", () => {
|
|
it("renders basic markdown features used by browser dialogues", () => {
|
|
const html = renderMessageMarkdown("# Title\n\n| left | right |\n| --- | --- |\n| a | b |\n");
|
|
|
|
expect(html).toContain("<h1>Title</h1>");
|
|
expect(html).toContain("<table>");
|
|
expect(html).toContain("<td>a</td>");
|
|
});
|
|
|
|
it("escapes inline HTML instead of rendering it", () => {
|
|
const html = renderMessageMarkdown("Before<script>alert('xss')</script>After");
|
|
|
|
expect(html).not.toContain("<script>");
|
|
expect(html).toContain("<script>alert('xss')</script>");
|
|
});
|
|
|
|
it("opens Markdown links safely in a new tab", () => {
|
|
const html = renderMessageMarkdown("[docs](https://example.com)");
|
|
|
|
expect(html).toContain('target="_blank"');
|
|
expect(html).toContain('rel="noopener noreferrer"');
|
|
});
|
|
});
|