|
1 | | -import { expect, it } from "vite-plus/test"; |
| 1 | +import { expect, it, vi } from "vite-plus/test"; |
2 | 2 |
|
3 | 3 | import { render } from "../../../test/render"; |
4 | 4 | import "../../index.css"; |
@@ -38,12 +38,17 @@ it.each(["plain", "formatted"] as const)( |
38 | 38 |
|
39 | 39 | const longUrl = url(16_000); |
40 | 40 | await screen.rerender(link(longUrl)); |
41 | | - const anchor = screen.container.querySelector("a")!; |
42 | | - const table = screen.container.querySelector("table")!; |
43 | | - expect(anchor.getAttribute("href")).toBe(longUrl); |
44 | | - expect(anchor.textContent).toBe(longUrl + (kind === "formatted" ? " details" : "")); |
45 | | - expect(anchor.querySelectorAll("*")).toHaveLength(initialElementCount); |
46 | | - if (kind === "formatted") expect(anchor.querySelector("strong")?.textContent).toBe(" details"); |
47 | | - expect(table.scrollWidth).toBeLessThanOrEqual(screen.container.firstElementChild!.clientWidth); |
| 41 | + await vi.waitFor(() => { |
| 42 | + const anchor = screen.container.querySelector("a")!; |
| 43 | + const table = screen.container.querySelector("table")!; |
| 44 | + expect(anchor.getAttribute("href")).toBe(longUrl); |
| 45 | + expect(anchor.textContent).toBe(longUrl + (kind === "formatted" ? " details" : "")); |
| 46 | + expect(anchor.querySelectorAll("*")).toHaveLength(initialElementCount); |
| 47 | + if (kind === "formatted") |
| 48 | + expect(anchor.querySelector("strong")?.textContent).toBe(" details"); |
| 49 | + expect(table.scrollWidth).toBeLessThanOrEqual( |
| 50 | + screen.container.firstElementChild!.clientWidth, |
| 51 | + ); |
| 52 | + }); |
48 | 53 | }, |
49 | 54 | ); |
0 commit comments