File tree Expand file tree Collapse file tree 3 files changed +3
-20
lines changed
nextjs-vite/src/export-mocks/navigation
nextjs/src/export-mocks/navigation Expand file tree Collapse file tree 3 files changed +3
-20
lines changed Original file line number Diff line number Diff line change 1- import type { MockInstance , Mock as MockV2 } from '@vitest/spy' ;
1+ import type { Mock , MockInstance } from '@vitest/spy' ;
22import {
33 type MaybeMocked ,
44 type MaybeMockedDeep ,
@@ -33,24 +33,7 @@ export const spyOn: typeof vitestSpyOn = (...args) => {
3333
3434type Procedure = ( ...args : any [ ] ) => any ;
3535
36- // TODO: Remove in 9.0
37- export type Mock < T extends Procedure | any [ ] = any [ ] , R = any > = T extends Procedure
38- ? MockV2 < T >
39- : T extends any [ ]
40- ? MockV2 < ( ...args : T ) => R >
41- : never ;
42-
43- // V2
4436export function fn < T extends Procedure = Procedure > ( implementation ?: T ) : Mock < T > ;
45- // TODO: Remove in 9.0
46- // V1
47- export function fn < TArgs extends any [ ] = any , R = any > ( ) : Mock < ( ...args : TArgs ) => R > ;
48- export function fn < TArgs extends any [ ] = any [ ] , R = any > (
49- implementation : ( ...args : TArgs ) => R
50- ) : Mock < ( ...args : TArgs ) => R > ;
51- export function fn < TArgs extends any [ ] = any [ ] , R = any > (
52- implementation ?: ( ...args : TArgs ) => R
53- ) : Mock < ( ...args : TArgs ) => R > ;
5437export function fn ( implementation ?: Procedure ) {
5538 const mock = implementation ? vitestFn ( implementation ) : vitestFn ( ) ;
5639 return reactiveMock ( mock ) ;
Original file line number Diff line number Diff line change @@ -93,4 +93,4 @@ export const notFound = fn(actual.notFound).mockName('next/navigation::notFound'
9393interface Params {
9494 [ key : string ] : string | string [ ] ;
9595}
96- export const useParams = fn < [ ] , Params > ( actual . useParams ) . mockName ( 'next/navigation::useParams' ) ;
96+ export const useParams = fn < ( ) => Params > ( actual . useParams ) . mockName ( 'next/navigation::useParams' ) ;
Original file line number Diff line number Diff line change @@ -93,4 +93,4 @@ export const notFound = fn(actual.notFound).mockName('next/navigation::notFound'
9393interface Params {
9494 [ key : string ] : string | string [ ] ;
9595}
96- export const useParams = fn < [ ] , Params > ( actual . useParams ) . mockName ( 'next/navigation::useParams' ) ;
96+ export const useParams = fn < ( ) => Params > ( actual . useParams ) . mockName ( 'next/navigation::useParams' ) ;
You can’t perform that action at this time.
0 commit comments