Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Flavien Groisillier
react-tp4
Commits
c0e12e58
Commit
c0e12e58
authored
Jan 08, 2022
by
FlavGr
Browse files
Ex 9 : Testing LoginForm
parent
0217859f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/test/loginForm.test.js
0 → 100644
View file @
c0e12e58
import
{
render
,
screen
}
from
"
@testing-library/react
"
;
import
React
from
"
react
"
;
import
userEvent
from
"
@testing-library/user-event
"
;
import
LoginForm
from
"
../components/LoginForm
"
;
test
(
"
it should call its onClick prop when clicked
"
,
async
()
=>
{
const
handleClick
=
jest
.
fn
();
render
(
<
LoginForm
onSubmit
=
{
handleClick
}
/>
)
;
// On simule le click
await
userEvent
.
click
(
screen
.
getByText
(
"
Connexion
"
));
expect
(
handleClick
).
toHaveBeenCalled
();
});
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment