generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #170 from Arquisoft/150-increase-code-coverage
Added strenght check tests
- Loading branch information
Showing
2 changed files
with
43 additions
and
5 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
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 |
---|---|---|
|
@@ -33,7 +33,7 @@ describe('<AddUser />', () => { | |
|
||
}); | ||
|
||
const fillFormAndSubmit = (email, username, password, repeatPassword) => { | ||
const fillForm = (email, username, password, repeatPassword) => { | ||
const emailInput = screen.getByPlaceholderText('addUser.email_placeholder'); | ||
fireEvent.change(emailInput, { target: { value: email } }); | ||
|
||
|
@@ -45,6 +45,10 @@ describe('<AddUser />', () => { | |
|
||
const repeatPasswordInput = screen.getByPlaceholderText('addUser.repeat_password_placeholder'); | ||
fireEvent.change(repeatPasswordInput, { target: { value: repeatPassword } }); | ||
}; | ||
|
||
const fillFormAndSubmit = (email, username, password, repeatPassword) => { | ||
fillForm(email, username, password, repeatPassword) | ||
|
||
const submitButton = screen.getByText('addUser.register_button'); | ||
fireEvent.click(submitButton); | ||
|
@@ -70,7 +74,7 @@ describe('<AddUser />', () => { | |
fillFormAndSubmit('[email protected]', 'username', '01234567890123456789012345678901234567890123456789012345678901234', '01234567890123456789012345678901234567890123456789012345678901234'); | ||
expect(screen.getByText('addUser.error_password_maximum_length')).toBeInTheDocument(); | ||
//Username with spaces | ||
fillFormAndSubmit('[email protected]', 'user name', '12345678', '12345678'); | ||
fillFormAndSubmit('[email protected]', 'user name', 'NvtL+k?qg953tD8', 'NvtL+k?qg953tD8'); | ||
expect(screen.getByText('addUser.error_username_spaces')).toBeInTheDocument(); | ||
|
||
//Show various errors | ||
|
@@ -87,6 +91,23 @@ describe('<AddUser />', () => { | |
expect(axios.post).toHaveBeenCalledWith(expect.any(String), { email: '[email protected]' ,username: 'existing_user', password: '12345678', repeatPassword: "12345678" }); | ||
}); | ||
|
||
test('displays correct password strength messages', () => { | ||
fillForm('[email protected]', 'user name', '123456', '123456'); | ||
expect(screen.getByText(/addUser.very_weak_password/)).toBeInTheDocument(); | ||
|
||
fillForm('[email protected]', 'user name', 'Mario12@@', 'Mario12@@'); | ||
expect(screen.getByText(/addUser.weak_password/)).toBeInTheDocument(); | ||
|
||
fillForm('[email protected]', 'user name', 'NvtL+k?qg9', 'NvtL+k?qg9'); | ||
expect(screen.getByText(/addUser.good_password/)).toBeInTheDocument(); | ||
|
||
fillForm('[email protected]', 'user name', 'NvtL+k?qg953tD8', 'NvtL+k?qg953tD8'); | ||
expect(screen.getByText(/addUser.strong_password/)).toBeInTheDocument(); | ||
|
||
fillForm('[email protected]', 'user name', '', ''); | ||
expect(screen.getByText(/addUser.very_weak_password/)).toBeInTheDocument(); | ||
}) | ||
|
||
}); | ||
|
||
|