-
-
Save kopax/69ea35181d55593f8b3a51938e359ef4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { renderHook } from '@testing-library/react-hooks' | |
import { fireEvent, render } from '@testing-library/react-native' | |
import React from 'react' | |
import { ForgottenPassword } from 'features/auth/forgottenPassword/ForgottenPassword' | |
import { queryCache, reactQueryProviderHOC } from 'tests/reactQueryProviderHOC' | |
beforeEach(() => { | |
jest.resetAllMocks() | |
}) | |
async function afterHack() { | |
const { waitFor } = renderHook(() => null) | |
await waitFor(() => { | |
if (queryCache.isFetching) { | |
throw new Error('The react-query queryCache is still fetching') | |
} | |
}) | |
} | |
describe('<ForgottenPassword />', () => { | |
beforeEach(() => { | |
queryCache.clear({ notify: false }) | |
}) | |
afterEach(() => { | |
afterHack() | |
}) | |
it.only('should redirect to ResetPasswordEmailSent when password reset request is successful', async () => { | |
const { getByPlaceholderText, findByText } = renderPage() | |
const emailInput = getByPlaceholderText('tonadresse@email.com') | |
fireEvent.changeText(emailInput, 'john.doe@gmail.com') | |
const validateEmailButton = await findByText('Valider') | |
fireEvent.press(validateEmailButton) // <==== line that break | |
}) | |
}) | |
function renderPage() { | |
return render(reactQueryProviderHOC(<ForgottenPassword />)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment