The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { assert, describe, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { getProjectFilePickerMatches } from "./ProjectFilePicker.logic"; |
| 4 | |
| 5 | function pathsForQuery(entries: Parameters<typeof getProjectFilePickerMatches>[0], query: string) { |
| 6 | return getProjectFilePickerMatches(entries, query).map(({ name, path }) => ({ name, path })); |
| 7 | } |
| 8 | |
| 9 | describe("getProjectFilePickerMatches", () => { |
| 10 | it("matches ordered characters while allowing skipped characters", () => { |
| 11 | const fuzzyEntries = [ |
| 12 | { kind: "file", path: "src/TestFlags.tsx" }, |
| 13 | { kind: "file", path: "src/SubtestFlow.tsx" }, |
| 14 | { kind: "file", path: "src/useSubtestFlags.ts" }, |
| 15 | { |
| 16 | kind: "file", |
| 17 | path: "src/useSubtestFlags/useTabActivity.ts", |
| 18 | }, |
| 19 | ] as const; |
| 20 | |
| 21 | assert.deepEqual( |
| 22 | pathsForQuery(fuzzyEntries, "testf").map(({ name }) => name), |
| 23 | ["TestFlags.tsx", "SubtestFlow.tsx", "useSubtestFlags.ts", "useTabActivity.ts"], |
| 24 | ); |
| 25 | assert.deepEqual(getProjectFilePickerMatches(fuzzyEntries, "tsfl")[0], { |
| 26 | name: "TestFlags.tsx", |
| 27 | nameMatchIndices: [0, 2, 4, 5], |
| 28 | path: "src/TestFlags.tsx", |
| 29 | pathMatchIndices: [4, 6, 8, 9], |
| 30 | }); |
| 31 | }); |
| 32 | |
| 33 | it("normalizes path prefixes consistently with server search", () => { |
| 34 | assert.deepEqual( |
| 35 | getProjectFilePickerMatches([{ kind: "file", path: "src/index.ts" }], "@/src")[0] |
| 36 | ?.pathMatchIndices, |
| 37 | [0, 1, 2], |
| 38 | ); |
| 39 | }); |
| 40 | }); |