Last active
August 2, 2019 20:13
-
-
Save yanmendes/b0e2f574f8d5ff141dbd75ac6987784e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { render, fireEvent } from '@testing-library/react' | |
test('should submit a valid form', () => { | |
const { getByLabelText, getByText } = render(<App />) | |
const setValue = value => ({ target: { value } }) | |
const password = '123456' | |
const email = '[email protected]' | |
fireEvent.input(getByLabelText('Email'), setValue(email)) | |
fireEvent.input(getByLabelText('Password'), setValue(password)) | |
fireEvent.input(getByLabelText('Confirm your password'), setValue(password)) | |
fireEvent.click(getByText('Submit')) | |
expect(axios.post).toHaveBeenCalledWith('http://localhost:5000', { | |
email, | |
password | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment