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

middle-truncate.browser.test.tsx

26 lines883 Bytes

1import { describe, expect, it } from "vite-plus/test";
2​
3import { render } from "../../../test/render";
4import { MiddleTruncate } from "./middle-truncate";
5​
6import "~/index.css";
7​
8const narrow = (value: string) => (
9 <div style={{ width: 80 }}>
10 <MiddleTruncate value={value} className="w-full" />
11 </div>
12);
13​
14describe("MiddleTruncate", () => {
15 it("does not clip a short value that replaces a truncated one", async () => {
16 await using screen = await render(narrow("t3/investigate-release-build-times"));
17 const label = () => screen.container.querySelector("[title] > span");
18 await expect.poll(() => label()?.hasAttribute("data-overflow")).toBe(true);
19​
20 await screen.rerender(narrow("main"));
21​
22 expect(label()).toHaveTextContent("main");
23 expect(label()).not.toHaveAttribute("data-overflow");
24 expect(label()).toHaveStyle({ clipPath: "none" });
25 });
26});