Files
rea/src/domain/analysisSearch.test.ts
T
morluto 9a3780229b test(search): pin native Unicode substring matching
The shared literal owner already applies Unicode simple folding. Verify the reported production-helper cases across insensitive literal, sensitive literal and regex selection.

Fixes #6634
2026-10-24 00:11:41 +08:00

54 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { expect, it } from "vitest";
import {
analysisSearchPredicate,
literalSubstringPredicate,
} from "./analysisSearch.js";
it("uses Unicode simple case folding for literal substrings", () => {
const matchesSigma = literalSubstringPredicate("Σ", false);
expect(matchesSigma("ΟΣ")).toBe(true);
expect(matchesSigma("ος")).toBe(true);
expect(matchesSigma("unrelated")).toBe(false);
expect(literalSubstringPredicate("Σ", true)("ος")).toBe(false);
expect(literalSubstringPredicate("A.B", false)("a.b")).toBe(true);
expect(literalSubstringPredicate("A.B", false)("axb")).toBe(false);
});
it.each([
["Σ", "ΟΣ"],
["σ", "ΟΣ"],
["ς", "ΟΣ"],
["Σ", "ΣA"],
["foo", "FOO"],
["ΟΣ", "ΟΣ"],
])(
"retains native literal match %s in %s when case is ignored",
(pattern, value) => {
expect(
analysisSearchPredicate({
pattern,
mode: "literal",
case_sensitive: false,
document: undefined,
})(value),
).toBe(true);
expect(
analysisSearchPredicate({
pattern,
mode: "literal",
case_sensitive: true,
document: undefined,
})(value),
).toBe(value.includes(pattern));
expect(
analysisSearchPredicate({
pattern,
mode: "regex",
case_sensitive: false,
document: undefined,
})(value),
).toBe(true);
},
);