Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Docs: a workspace knowledge base people and agents write together | 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; | |
| 3 | ||
| 4 | import { ftsQuery, inProject, projectRef, searchSpaces } from "./search.ts"; | |
| 5 | ||
| 6 | test("queries are quoted word by word, the last a prefix", () => { | |
| 7 | assert.equal(ftsQuery("deploy run"), '"deploy" "run"*'); | |
| 8 | assert.equal(ftsQuery('NEAR(a b) OR "x" -y'), '"near" "a" "b" "or" "x" "y"*'); | |
| 9 | assert.equal(ftsQuery(" -- "), null); | |
| 10 | }); | |
| 11 | ||
| 12 | test("a search looks only in spaces the reader can read", () => { | |
| 13 | assert.deepEqual(searchSpaces(["s1", "s2"], null), ["s1", "s2"]); | |
| 14 | assert.deepEqual(searchSpaces(["s1", "s2"], "s2"), ["s2"]); | |
| 15 | assert.deepEqual(searchSpaces(["s1"], "s3"), []); | |
| 16 | }); | |
| 17 | ||
| 18 | test("a project filter matches the page's projects or its space's", () => { | |
| 19 | assert.equal(inProject("acme/web", ["acme/web"], []), true); | |
| 20 | assert.equal(inProject("acme/web", [], ["Acme/Web"]), true); | |
| 21 | assert.equal(inProject("acme/web", ["acme/api"], []), false); | |
| 22 | assert.equal(inProject(null, [], []), true); | |
| 23 | assert.equal(projectRef(" Acme/Web/ "), "acme/web"); | |
| 24 | assert.equal(projectRef("nope"), null); | |
| 25 | }); |