Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

threadFindHighlights.browser.test.tsx

23 lines807 Bytes

1import { describe, expect, it } from "vite-plus/test";
2​
3import { collectThreadFindRanges } from "./threadFindHighlights";
4​
5function row(html: string) {
6 const container = document.createElement("div");
7 container.innerHTML = `<div data-timeline-row-id="row"><div data-thread-find-text>${html}</div></div>`;
8 return container;
9}
10​
11describe("collectThreadFindRanges", () => {
12 it("finds matches split across inline token spans, in order", () => {
13 const container = row(
14 "<pre><code><span>con</span><span>st</span> a = <span>c</span>onst; const</code></pre>",
15 );
16 const ranges = collectThreadFindRanges(container, "const");
17 expect(ranges.map((match) => [match.occurrence, match.range.toString()])).toEqual([
18 [0, "const"],
19 [1, "const"],
20 [2, "const"],
21 ]);
22 });
23});