diff --git a/src/hooks/useDrawerUrlState.test.ts b/src/hooks/useDrawerUrlState.test.ts index 9819bb7..3185534 100644 --- a/src/hooks/useDrawerUrlState.test.ts +++ b/src/hooks/useDrawerUrlState.test.ts @@ -58,11 +58,13 @@ function setLocation(url: string): void { describe("useDrawerUrlState", () => { // `vi.fn()` with no args in vitest 4 is typed `Mock`, which carries a constructor signature and won't - // assign to `() => void`. Constraining the generic to `vi.fn<() => void>()` - // gives a plain function-typed mock that flows directly into `pushState` - // / `replaceState` slots. - let pushStateMock: ReturnType void>>; - let replaceStateMock: ReturnType void>>; + // assign to a real `pushState` slot. Constrain the generic to the + // `History.pushState` signature so the mock flows into `vi.stubGlobal` + // without complaint AND `mock.calls[0]` is typed as a 3-tuple, letting + // us read `calls[0][2]` (the URL) without an `as unknown` cast. + type PushState = (state: unknown, unused: string, url?: string | URL | null) => void; + let pushStateMock: ReturnType>; + let replaceStateMock: ReturnType>; beforeEach(() => { pushStateMock = vi.fn();