Files
t3code/packages/shared/src/threadSearch.test.ts
T
12069eefd7 feat(web): find messages and plans in the current thread (#10439)
Co-authored-by: Yash Singh <[email protected]>
Co-authored-by: Julius Marminge <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-08 08:24:50 -05:00

24 lines
1.1 KiB
TypeScript

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