test: lock in process, ripgrep, and installation helpers

This commit is contained in:
Dax Raad
2026-03-07 19:21:22 -05:00
parent 9dc8ac4734
commit e6d1aae33a
3 changed files with 97 additions and 0 deletions

View File

@@ -36,4 +36,38 @@ describe("file.ripgrep", () => {
expect(hasVisible).toBe(true)
expect(hasHidden).toBe(false)
})
test("search returns match metadata", async () => {
await using tmp = await tmpdir({
init: async (dir) => {
await Bun.write(path.join(dir, "match.ts"), "const value = 'needle'\n")
await Bun.write(path.join(dir, "other.ts"), "const value = 'other'\n")
},
})
const hits = await Ripgrep.search({
cwd: tmp.path,
pattern: "needle",
})
expect(hits.length).toBe(1)
expect(hits[0]?.path.text).toBe("match.ts")
expect(hits[0]?.line_number).toBe(1)
expect(hits[0]?.lines.text).toContain("needle")
})
test("search returns empty when nothing matches", async () => {
await using tmp = await tmpdir({
init: async (dir) => {
await Bun.write(path.join(dir, "match.ts"), "const value = 'other'\n")
},
})
const hits = await Ripgrep.search({
cwd: tmp.path,
pattern: "needle",
})
expect(hits).toEqual([])
})
})