diff --git a/__tests__/AuthScreen-test.tsx b/__tests__/AuthScreen-test.tsx index 1878f4b2..e1c14fc1 100644 --- a/__tests__/AuthScreen-test.tsx +++ b/__tests__/AuthScreen-test.tsx @@ -4,9 +4,9 @@ import AuthScreen from '../src/screens/AuthScreen/AuthScreen'; import Strings from '../src/i18n/en'; import { Provider } from 'react-redux'; import { configureStore } from '@reduxjs/toolkit'; -import { customRenderWithProvider } from '../src/utils/tests'; import { Linking } from 'react-native'; import AuthApis from '../src/constants/apiConstant/AuthApi'; +import ProviderWrapper from './ProviderWrapper'; jest.mock('react-redux', () => { return { @@ -22,7 +22,11 @@ jest.mock('react-native/Libraries/Linking/Linking', () => ({ })); it('AuthScreen is rendered', () => { - customRenderWithProvider(AuthScreen); + render( + + + + ); screen.getByText(/welcome to/i); screen.getByText(/real dev squad/i); }); @@ -42,7 +46,11 @@ it('Clicking on Sign in with Github opens browser', async () => { const baseUrl = AuthApis.GITHUB_AUTH_API; const githubUrl = mockBuildUrl(baseUrl, queryParams); - customRenderWithProvider(AuthScreen); + render( + + + + ); const githubSignInBtn = screen.getByText(Strings.SIGN_IN_BUTTON_TEXT); fireEvent.press(githubSignInBtn); diff --git a/__tests__/ProviderWrapper.tsx b/__tests__/ProviderWrapper.tsx new file mode 100644 index 00000000..9beaadc3 --- /dev/null +++ b/__tests__/ProviderWrapper.tsx @@ -0,0 +1,18 @@ +import React, { ReactNode } from 'react'; +import { Provider as StoreProvider } from 'react-redux'; +import { AuthProvider } from '../src/context/AuthContext'; +import { store } from '../App'; + +interface ProviderWrapperProps { + children: ReactNode; +} + +const ProviderWrapper: React.FC = ({ children }) => ( + + + <>{children} + + +); + +export default ProviderWrapper; diff --git a/src/utils/tests/index.tsx b/src/utils/tests/index.tsx deleted file mode 100644 index 69c189b1..00000000 --- a/src/utils/tests/index.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import React from 'react'; -import { Provider as StoreProvider } from 'react-redux'; -import { AuthProvider } from '../../context/AuthContext'; -import { store } from '../../../App'; -import { - render, - RenderOptions, - RenderResult, -} from '@testing-library/react-native'; -import Toast from 'react-native-toast-message'; - -export function customRenderWithProvider( - Component: React.FC, - renderOptions?: RenderOptions, -): RenderResult { - return render( - - - - - , - renderOptions, - ); -} - -export const withToast = (Component: React.FC) => { - return () => ( - <> - - - - ); -};