11/**
22 * @vitest -environment jsdom
33 */
4- import { act , type ReactNode } from 'react'
4+ import { act , type ReactNode , useEffect , useState } from 'react'
55import { createRoot , type Root } from 'react-dom/client'
66import { afterEach , beforeEach , describe , expect , it , vi } from 'vitest'
77import { ApiClientError } from '@/lib/api/client/errors'
@@ -50,8 +50,7 @@ vi.mock('next/navigation', () => ({
5050 useSearchParams : ( ) => mockSearchParams . current ,
5151} ) )
5252
53- vi . mock ( '@tanstack/react-query' , async ( ) => {
54- const React = await import ( 'react' )
53+ vi . mock ( '@tanstack/react-query' , ( ) => {
5554 return {
5655 useQueryClient : ( ) => ( {
5756 cancelQueries : mockCancelQueries ,
@@ -66,13 +65,13 @@ vi.mock('@tanstack/react-query', async () => {
6665 queryFn : ( context : { signal ?: AbortSignal } ) => Promise < unknown >
6766 enabled ?: boolean
6867 } ) => {
69- const [ state , setState ] = React . useState < {
68+ const [ state , setState ] = useState < {
7069 data : unknown
7170 error : unknown
7271 isPending : boolean
7372 } > ( { data : undefined , error : null , isPending : true } )
7473 const enabled = options . enabled !== false
75- React . useEffect ( ( ) => {
74+ useEffect ( ( ) => {
7675 if ( ! enabled ) return
7776 let cancelled = false
7877 options . queryFn ( { } ) . then (
@@ -108,10 +107,11 @@ vi.mock('@/lib/auth/auth-client', () => ({
108107 useSession : mockUseSession ,
109108} ) )
110109
111- vi . mock ( '@/app/invite/components' , async ( ) => ( {
112- InvitationDisclosure : ( await import ( '@/app/invite/components/invitation-disclosure' ) )
113- . InvitationDisclosure ,
114- InviteLayout : ( { children } : { children : ReactNode } ) => children ,
110+ vi . mock ( '@/app/invite/components/layout' , ( ) => ( {
111+ default : ( { children } : { children : ReactNode } ) => children ,
112+ } ) )
113+
114+ vi . mock ( '@/app/invite/components/status-card' , ( ) => ( {
115115 InviteStatusCard : ( {
116116 actions = [ ] ,
117117 description,
0 commit comments