-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Messaging-Application/MA-16-user-registration
MA 16 - user registration
- Loading branch information
Showing
9 changed files
with
529 additions
and
8 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { render, fireEvent } from '@testing-library/react'; | ||
import '@testing-library/jest-dom' | ||
|
||
import Register from '../components/Register'; | ||
|
||
describe('Register component', () => { | ||
test('renders username, password, confirm fields', () => { | ||
const { getByLabelText } = render(<Register />); | ||
const usernameInput = getByLabelText('Username'); | ||
const passwordInput = getByLabelText('Password'); | ||
const confirmInput = getByLabelText('Confirm Password'); | ||
const emailInput = getByLabelText('Email'); | ||
const firstnameInput = getByLabelText('Firstname'); | ||
const lastnameInput = getByLabelText('Lastname'); | ||
|
||
expect(emailInput).toBeInTheDocument(); | ||
expect(firstnameInput).toBeInTheDocument(); | ||
expect(lastnameInput).toBeInTheDocument(); | ||
expect(usernameInput).toBeInTheDocument(); | ||
expect(passwordInput).toBeInTheDocument(); | ||
expect(confirmInput).toBeInTheDocument(); | ||
}); | ||
|
||
test('allows user to enter username, password, confirm', () => { | ||
const { getByLabelText } = render(<Register />); | ||
const usernameInput = getByLabelText('Username'); | ||
const passwordInput = getByLabelText('Password'); | ||
const confirmInput = getByLabelText('Confirm Password'); | ||
const emailInput = getByLabelText('Email'); | ||
const firstnameInput = getByLabelText('Firstname'); | ||
const lastnameInput = getByLabelText('Lastname'); | ||
|
||
fireEvent.change(usernameInput, { target: { value: 'testuser' } }); | ||
fireEvent.change(passwordInput, { target: { value: 'testpassword' } }); | ||
fireEvent.change(confirmInput, { target: { value: 'testpassword2' } }); | ||
fireEvent.change(emailInput, { target: { value: '[email protected]' } }); | ||
fireEvent.change(firstnameInput, { target: { value: 'testfisrtname' } }); | ||
fireEvent.change(lastnameInput, { target: { value: 'testlastname' } }); | ||
|
||
expect(emailInput).toHaveValue('[email protected]'); | ||
expect(firstnameInput).toHaveValue('testfisrtname'); | ||
expect(lastnameInput).toHaveValue('testlastname'); | ||
expect(usernameInput).toHaveValue('testuser'); | ||
expect(passwordInput).toHaveValue('testpassword'); | ||
expect(confirmInput).toHaveValue('testpassword2'); | ||
}); | ||
|
||
test('submits form with username, password, confirm when Sign up button is clicked', async () => { | ||
const { getByLabelText } = render(<Register />); | ||
const usernameInput = getByLabelText('Username'); | ||
const passwordInput = getByLabelText('Password'); | ||
const confirmInput = getByLabelText('Confirm Password'); | ||
const emailInput = getByLabelText('Email'); | ||
const firstnameInput = getByLabelText('Firstname'); | ||
const lastnameInput = getByLabelText('Lastname'); | ||
// const signUpButton = getByText('Sign up'); | ||
|
||
fireEvent.change(usernameInput, { target: { value: 'testuser' } }); | ||
fireEvent.change(passwordInput, { target: { value: 'testpassword' } }); | ||
fireEvent.change(confirmInput, { target: { value: 'testpassword2' } }); | ||
fireEvent.change(emailInput, { target: { value: '[email protected]' } }); | ||
fireEvent.change(firstnameInput, { target: { value: 'testfisrtname' } }); | ||
fireEvent.change(lastnameInput, { target: { value: 'testlastname' } }); | ||
// fireEvent.click(signUpButton); | ||
}); | ||
|
||
}); |
Oops, something went wrong.