docs: fix unreachable shared-prefix test cases in plan Task 2

The guard tests used 3-char query tokens whose field tokens were literal
continuations ('car'/'carpet'), so the startsWith rule returned 0.9 before
the shared-prefix rule was reached. With MIN_SHARED_PREFIX=4 the rule is
unreachable for any 3-char token, making the assertion impossible to
satisfy. Swapped in cases where neither token is a true prefix of the
other, which actually exercise the guard.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
Lucas Winther
2026-09-17 10:26:54 +02:00
co-authored by Claude Opus 5
parent 28a834eb32
commit c4e303c8b7
+7 -3
View File
@@ -342,13 +342,17 @@ describe("scoreToken", () => {
});
test("matches morphological variants via a shared prefix", () => {
// Neither token is a true prefix of the other, so these exercise the
// shared-prefix rule rather than being intercepted by the startsWith rule.
expect(scoreToken("decide", "decision")).toBeGreaterThan(0.5);
expect(scoreToken("deploy", "deployment")).toBeGreaterThan(0.5);
expect(scoreToken("deployed", "deployment")).toBeGreaterThan(0.5);
});
test("does not shared-prefix-match on fewer than 4 common characters", () => {
expect(scoreToken("car", "carpet")).toBeLessThan(0.9);
expect(scoreToken("bee", "beetle")).toBeLessThan(0.9);
// "cars"/"carton" share only "car" (3 < MIN_SHARED_PREFIX) and neither is
// a true prefix of the other, so every rule falls through to zero.
expect(scoreToken("cars", "carton")).toBe(0);
expect(scoreToken("bees", "beetle")).toBe(0);
});
test("ranks a shared-prefix match below a true prefix match", () => {