1import { expect, it } from "vite-plus/test";
2import { findThreadSearchOccurrences, splitThreadSearchText } from "./threadSearch.ts";
3
4it("finds non-overlapping occurrences without invalidating Unicode offsets", () => {
5 expect(findThreadSearchOccurrences("Deploy the Deployment", "deploy")).toEqual([0, 11]);
6 expect(findThreadSearchOccurrences("aaaa", "aa")).toEqual([0, 2]);
7 expect(findThreadSearchOccurrences("İİİ needle", "needle")).toEqual([4]);
8});
9
10it("splits search text into highlighted and unhighlighted parts", () => {
11 expect(splitThreadSearchText("one TWO three two", " two ")).toEqual([
12 { text: "one ", highlighted: false, start: 0 },
13 { text: "TWO", highlighted: true, start: 4 },
14 { text: " three ", highlighted: false, start: 7 },
15 { text: "two", highlighted: true, start: 14 },
16 ]);
17});
18
19it("matches both Greek sigma forms without changing source offsets", () => {
20 expect(findThreadSearchOccurrences("ΟΣ ος οσ", "Σ")).toEqual([1, 4, 7]);
21 expect(findThreadSearchOccurrences("ΟΣ ος οσ", "ς")).toEqual([1, 4, 7]);
22 expect(findThreadSearchOccurrences("İ ΟΣ", "Σ")).toEqual([3]);
23});