Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/llms-txt-hub / apps/web/__tests__/utils/test-providers.tsx |
| Date | Not specified in source |
| Repository | Janady13/llms-txt-hub |
| Revision | e0f4bf978d4df168369c7601d9c5f5ea89e84377 |
| Branch | main |
| Path or archive member | apps/web/__tests__/utils/test-providers.tsx |
| Original SHA-256 | 50b136eb7e6f32633037d1519cbcceab0454f88d0d5d46e975ffa49763f1d547 |
| Git blob SHA | 9436586f01381325e02bdec757e2862e72cc24dd |
| Reading-copy SHA-256 | 50b136eb7e6f32633037d1519cbcceab0454f88d0d5d46e975ffa49763f1d547 |
Recovered source transcript
Download complete source text ↓70 lines · 1.6 KB
/**
* Test provider components and utilities
*/
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import type { RenderOptions } from '@testing-library/react'
import { ThemeProvider } from 'next-themes'
import type { ReactNode } from 'react'
import { FavoritesProvider } from '@/contexts/favorites-context'
export interface CustomRenderOptions extends Omit<RenderOptions, 'wrapper'> {
user?: any
isAuthenticated?: boolean
theme?: 'light' | 'dark'
queryClient?: QueryClient
wrapperProps?: Record<string, any>
}
/**
* Creates a test query client with default configuration
*
* @returns Configured QueryClient for testing
*/
export function createTestQueryClient() {
return new QueryClient({
defaultOptions: {
queries: {
retry: false,
gcTime: 0
},
mutations: {
retry: false
}
}
})
}
/**
* Wrapper component that provides all necessary contexts for testing
*
* @param props - Component props
* @returns React component with all providers
*/
export function TestProviders({
children,
queryClient,
theme = 'light'
}: {
children: ReactNode
queryClient?: QueryClient
theme?: 'light' | 'dark'
user?: any
isAuthenticated?: boolean
}) {
const testQueryClient = queryClient || createTestQueryClient()
return (
<QueryClientProvider client={testQueryClient}>
<ThemeProvider
attribute="class"
defaultTheme={theme}
enableSystem={false}
disableTransitionOnChange
>
<FavoritesProvider>{children}</FavoritesProvider>
</ThemeProvider>
</QueryClientProvider>
)
}