evOo-local/packages/core/src/search.test.ts
cynarAI 6c7eed7580 Initial clean evOo-local from f00577b
Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline
(Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/*
packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
2026-09-20 17:15:16 +02:00

37 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
extractLinksFromText,
matchesSearchQuery,
searchHitThreadTarget,
snippetAroundMatch,
} from "./search.js";
describe("search helpers", () => {
it("extracts http and https links from text", () => {
expect(extractLinksFromText("see https://example.com/docs and http://test.local/x.")).toEqual([
"https://example.com/docs",
"http://test.local/x",
]);
});
it("matches case-insensitive substrings", () => {
expect(matchesSearchQuery("Venue", "Research venues")).toBe(true);
expect(matchesSearchQuery("missing", "Research venues")).toBe(false);
});
it("builds a short snippet around the query", () => {
const text = "alpha beta gamma delta epsilon zeta eta theta";
expect(snippetAroundMatch(text, "gamma", 20)).toContain("gamma");
});
it("uses groupId for group search message jumps", () => {
expect(searchHitThreadTarget({ groupId: "group-1" })).toEqual({ groupId: "group-1" });
expect(searchHitThreadTarget({ botId: "bot-1" })).toEqual({ botId: "bot-1" });
});
it("rejects ambiguous search hit targets", () => {
expect(() => searchHitThreadTarget({})).toThrow();
expect(() => searchHitThreadTarget({ botId: "bot-1", groupId: "group-1" })).toThrow();
});
});