-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to ensure fields are not validation until touched
- Loading branch information
Showing
3 changed files
with
17 additions
and
2 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
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 |
---|---|---|
|
@@ -164,3 +164,14 @@ test('Field validation runs on change, after submitting', async () => { | |
//ensure the validation shows up | ||
expect(getByText('This field is required')).toBeInTheDocument(); | ||
}); | ||
|
||
test(`Untouched fields shouldn't validate unless submitted first`, () => { | ||
let { queryByPlaceholderText, queryByText } = render(<TestForm />); | ||
const email = queryByPlaceholderText('email'); | ||
|
||
fireEvent.focus(email); | ||
fireEvent.change(email, { target: { value: '[email protected]' } }); | ||
fireEvent.blur(email); | ||
|
||
expect(queryByText('This field is required')).toBeNull(); | ||
}); |