1import { expect, it } from "vite-plus/test";
2import { prepareSourceFileDocument, selectableSourceHtml } from "./source-file-document";
3β
4it("preserves source whitespace and markup as literal selectable text", () => {
5 const source = prepareSourceFileDocument(
6 "\n\tlead\r\n<script>alert(1)</script> & > π\u00a0end\n",
7 );
8 const html = selectableSourceHtml(source.contents, {
9 foreground: "#000000",
10 selection: "#3366ff",
11 fontSize: 14,
12 rowHeight: 24,
13 wordBreak: true,
14 });
15 const page = new DOMParser().parseFromString(html, "text/html");
16β
17 expect(page.querySelector("script")).toBeNull();
18 expect(page.body.textContent).toBe("\n\tlead\n<script>alert(1)</script> & > π\u00a0end\n");
19 expect(page.getElementById("L2")?.textContent).toBe("\tlead");
20});