| 1 | import { describe, expect, it } from "bun:test"; |
| 2 | |
| 3 | import { rankPaths } |
| 4 | |
| 5 | describe("rankPaths", () |
| 6 | const paths = |
| 7 | "button/index.ts", |
| 8 | "src/components/ui/button.tsx", |
| 9 | "src/lib/utils.ts", |
| 10 | "README.md", |
| 11 | ]; |
| 12 | |
| 13 | it("ranks a file-name match above a match in the directories", |
| 14 | expect(rankPaths(paths |
| 15 | "src/components/ui/button.tsx", |
| 16 | "button/index.ts", |
| 17 | ]); |
| 18 | }); |
| 19 | |
| 20 | it("matches a subsequence, ignoring case and spaces", |
| 21 | expect(rankPaths(paths |
| 22 | expect(rankPaths(paths |
| 23 | }); |
| 24 | |
| 25 | it("drops paths that do not hold the query", |
| 26 | expect(rankPaths(paths |
| 27 | }); |
| 28 | |
| 29 | it("caps the result and lists everything for an empty query", |
| 30 | expect(rankPaths(paths |
| 31 | }); |
| 32 | }); |