The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { expect, it } from "vite-plus/test"; |
| 2 | import { prepareSourceFileDocument, selectableSourceHtml } from "./source-file-document"; |
| 3 | |
| 4 | it("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 | }); |