Skip to content

Commit

Permalink
added tsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
gkbishnoi07 committed Jan 15, 2025
1 parent 91547bd commit 3833bb8
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions src/components/test-utils/TestWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,44 @@
import type { ReactNode } from 'react';
import React from 'react';
import type { MockedResponse } from '@apollo/client/testing';
import { MockedProvider } from '@apollo/client/testing';
import type { MockedResponse } from '@apollo/react-testing';
import { MockedProvider } from '@apollo/react-testing';
import type { ReactNode } from 'react';
import { I18nextProvider } from 'react-i18next';
import { BrowserRouter } from 'react-router-dom';
import i18n from 'i18next';
import i18n from 'utils/i18n';

/**
* Props for the TestWrapper component.
*/
interface InterfaceTestWrapperProps {
/** The React components to be wrapped */
children: ReactNode;
/** Optional Apollo GraphQL mocks for testing queries and mutations */
mocks?: MockedResponse[];
}

/**
* A wrapper component for testing React components that require Apollo Client, i18n, and Router contexts.
* Provides the necessary provider context for testing components that use GraphQL, translations, and routing.
*
* @example
* ```tsx
* const mocks = [{
* request: { query: TEST_QUERY },
* result: { data: { test: 'data' } }
* }];
*
* render(
* <TestWrapper mocks={mocks}>
* <ComponentToTest />
* </TestWrapper>
* );
* ```
*
* @param props - The component props
* @param children - The React components to be wrapped
* @param mocks - Optional Apollo GraphQL mocks for testing queries and mutations
* @returns A JSX element with all required providers wrapped around the children
*/
export const TestWrapper = ({
children,
mocks = [],
Expand Down

0 comments on commit 3833bb8

Please sign in to comment.