Files
portainer/app/react/test-utils/withTestQuery.tsx
T
LP B 0c2f07988a feat(app/sources): source create view (#2680)
Co-authored-by: Chaim Lev-Ari <chaim.lev-ari@portainer.io>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 21:34:46 +03:00

26 lines
740 B
TypeScript

import { ComponentType } from 'react';
import { MutationCache, QueryCache, QueryClient } from '@tanstack/react-query';
import { withReactQuery } from '@/react-tools/withReactQuery';
export function withTestQueryProvider<T>(
WrappedComponent: ComponentType<T & JSX.IntrinsicAttributes>,
{
onMutationError,
onQueryError,
}: {
onMutationError?(error: unknown): void;
onQueryError?(error: unknown): void;
} = {}
) {
const testQueryClient = new QueryClient({
defaultOptions: { queries: { retry: false } },
queryCache: new QueryCache({ onError: onQueryError }),
mutationCache: new MutationCache({
onError: onMutationError,
}),
});
return withReactQuery(WrappedComponent, testQueryClient);
}