|
1 | 1 | import { createContext, createElement } from "react"; |
2 | | -import { describe, expect, it } from "vitest"; |
| 2 | +import { describe, expect, it, vi } from "vitest"; |
3 | 3 | import { render, screen } from "@testing-library/react"; |
4 | 4 | import { userEvent } from "@testing-library/user-event"; |
5 | 5 |
|
@@ -29,7 +29,7 @@ import { |
29 | 29 | wheelZoom, |
30 | 30 | withFakeTimers, |
31 | 31 | } from "./test-utils"; |
32 | | -import { useZoom } from "../src/components"; |
| 32 | +import { useZoom } from "../src"; |
33 | 33 | import { makeUseContext } from "../src/utils"; |
34 | 34 |
|
35 | 35 | declare module "../src/types" { |
@@ -206,25 +206,31 @@ describe("Lightbox", () => { |
206 | 206 | }); |
207 | 207 |
|
208 | 208 | it("supports view transitions", () => { |
209 | | - document.startViewTransition = (callback) => { |
| 209 | + const startViewTransitionBackup = document.startViewTransition; |
| 210 | + |
| 211 | + document.startViewTransition = vi.fn().mockImplementation((callback) => { |
210 | 212 | callback?.(); |
211 | 213 |
|
212 | 214 | return { |
213 | 215 | ready: Promise.resolve(undefined), |
214 | 216 | finished: Promise.resolve(undefined), |
215 | 217 | updateCallbackDone: Promise.resolve(undefined), |
216 | 218 | skipTransition() {}, |
217 | | - }; |
218 | | - }; |
| 219 | + types: { |
| 220 | + forEach() {}, |
| 221 | + }, |
| 222 | + } satisfies ViewTransition; |
| 223 | + }); |
219 | 224 |
|
220 | 225 | renderLightbox(); |
221 | 226 | expectCurrentSlideToBe(0); |
222 | 227 |
|
223 | 228 | clickButtonNext(); |
224 | 229 | expectCurrentSlideToBe(1); |
225 | 230 |
|
226 | | - // @ts-expect-error - expected error |
227 | | - document.startViewTransition = undefined; |
| 231 | + expect(document.startViewTransition).toHaveBeenCalled(); |
| 232 | + |
| 233 | + document.startViewTransition = startViewTransitionBackup; |
228 | 234 | }); |
229 | 235 |
|
230 | 236 | it("supports custom styles", () => { |
|
0 commit comments