import { describe, it, expect } from "vitest"; import { cleanQuillHtml } from "../utils/pdf-shared"; describe("cleanQuillHtml — inline-style whitelist", () => { it("keeps Quill text and background colors", () => { const html = '

červeně ' + 'zvýrazněně ' + 'modře

'; const out = cleanQuillHtml(html); expect(out).toContain('style="color: rgb(230, 0, 0)"'); expect(out).toContain('style="background-color: #ffff00"'); expect(out).toContain('style="color: #06c"'); }); it("drops every non-color style declaration", () => { const out = cleanQuillHtml( 'x', ); expect(out).toBe('x'); }); it("drops unsafe color values (url, expression, quotes)", () => { expect( cleanQuillHtml('x'), ).toBe("x"); expect( cleanQuillHtml('x'), ).toBe("x"); expect(cleanQuillHtml("x")).toBe( "x", ); }); it("restores Quill 2's empty

blank lines to


", () => { // Quill 2's semantic HTML drops the
placeholder from blank lines. expect(cleanQuillHtml("

A

B

")).toBe( "

A


B

", ); // Attribute-carrying and whitespace-only empties too. expect(cleanQuillHtml('

')).toBe( '


', ); }); it("keeps stripping scripts, event handlers and js: URLs", () => { const out = cleanQuillHtml( '

' + 'x

', ); expect(out).not.toContain("script"); expect(out).not.toContain("onclick"); expect(out).not.toContain("javascript:"); }); });