const { expect } = require("chai");
const { marked } = require("marked");
const DOMPurify = require("isomorphic-dompurify");
/**
* Helper that mirrors the server-side rendering pipeline in webview.ts:
* DOMPurify.sanitize(marked.marked(content, { headerIds: false, mangle: false }))
*/
function renderAndSanitize(markdown) {
const raw = marked(markdown, { headerIds: false, mangle: false });
return DOMPurify.sanitize(raw);
}
describe("Markdown sanitization", function () {
// ---------------------------------------------------------------
// Script injection
// ---------------------------------------------------------------
describe("removes script tags", function () {
it("strips inline ');
expect(html).to.not.include("'
);
expect(html).to.not.include("\n\nWorld"
);
expect(html).to.not.include(""
);
expect(html).to.not.include("\n\n**Bold text**'
);
expect(html).to.not.include("