Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

StartTruncatedPath.test.tsx

31 lines1.2 KB

1import { renderToStaticMarkup } from "react-dom/server";
2import { describe, expect, it } from "vite-plus/test";
3​
4import { StartTruncatedPath } from "./StartTruncatedPath";
5​
6describe("StartTruncatedPath", () => {
7 it("keeps the filename at the visible end by truncating from the start", () => {
8 const path = "apps/desktop/src/components/very/long/CommitDialog.tsx";
9​
10 const markup = renderToStaticMarkup(<StartTruncatedPath path={path} />);
11​
12 expect(markup).toContain('dir="rtl"');
13 expect(markup).toMatch(
14 /<bdi[^>]*>apps\/desktop\/src\/components\/very\/long\/CommitDialog\.tsx<\/bdi>/,
15 );
16 expect(markup).toContain("overflow-hidden");
17 expect(markup).toContain("text-ellipsis");
18 expect(markup).toContain("whitespace-nowrap");
19 expect(markup).toContain("min-w-0");
20 });
21​
22 it("shows the full path in a tooltip", () => {
23 const path = "apps/desktop/src/components/very/long/CommitDialog.tsx";
24​
25 const markup = renderToStaticMarkup(<StartTruncatedPath path={path} />);
26​
27 expect(markup).toContain('data-slot="tooltip-trigger"');
28 expect(markup).toContain("data-base-ui-tooltip-trigger");
29 expect(markup).toContain(path);
30 });
31});