Skip to content

Instantly share code, notes, and snippets.

@yanmendes
Last active August 2, 2019 21:28
Show Gist options
  • Save yanmendes/14e110a51e2616aa1a43af954a2bb89c to your computer and use it in GitHub Desktop.
Save yanmendes/14e110a51e2616aa1a43af954a2bb89c to your computer and use it in GitHub Desktop.
it('should print a success message and redirect on a successful submission', async () => {
const Routes = () =>
<>
<Route path='/' exact component={App} />
<Route path='/success' exact component={Success} />
</>
const {
getByLabelText,
getByText,
findByText,
history
} = renderWithReduxAndRouter(<Routes />)
const password = '123456'
const email = 'foo@bar.com'
fireEvent.input(getByLabelText('Email'), setValue(email))
fireEvent.input(getByLabelText('Password'), setValue(password))
fireEvent.input(getByLabelText('Confirm your password'), setValue(password))
await fireEvent.click(getByText('Submit'))
const successMessage = await findByText(/Form sent successfully/)
expect(successMessage).toBeVisible()
expect(history.entries.pop().pathname).toBe('/success')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment