The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { splitForMiddleTruncate } from "./middle-truncate"; |
| 4 | |
| 5 | describe("splitForMiddleTruncate", () => { |
| 6 | it("keeps a short last path segment whole", () => { |
| 7 | expect(splitForMiddleTruncate("feature/ui-polish")).toEqual({ |
| 8 | head: "feature/", |
| 9 | tail: "ui-polish", |
| 10 | }); |
| 11 | }); |
| 12 | |
| 13 | it("starts a long segment's tail on a word, not mid-word", () => { |
| 14 | expect(splitForMiddleTruncate("t3/clone-repo-to-other-machine")?.tail).toBe("machine"); |
| 15 | expect(splitForMiddleTruncate("t3/investigate-release-build-times")?.tail).toBe("times"); |
| 16 | }); |
| 17 | |
| 18 | it("falls back to an earlier word when the last one is too short", () => { |
| 19 | expect(splitForMiddleTruncate("t3/compare-long-featurenames-ab")?.tail).toBe("featurenames-ab"); |
| 20 | }); |
| 21 | |
| 22 | it("keeps the fixed tail when no word break is near", () => { |
| 23 | expect(splitForMiddleTruncate("t3/abcdefghijklmnopqrstuvwxyz")?.tail).toBe("qrstuvwxyz"); |
| 24 | }); |
| 25 | |
| 26 | it("respects an explicit tail length", () => { |
| 27 | expect(splitForMiddleTruncate("t3/clone-repo-to-other-machine", 6)?.tail).toBe("achine"); |
| 28 | }); |
| 29 | }); |