-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements form in Home component to get user's name, tests that user…
…'s name is displayed on form submission
- Loading branch information
1 parent
0722e84
commit 0c08787
Showing
2 changed files
with
38 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { fireEvent, render, screen } from "@testing-library/react"; | ||
import Home from "./Home"; | ||
import "@testing-library/jest-dom"; | ||
|
||
test("user's name is displayed on form submission", () => { | ||
render(<Home />); | ||
|
||
const name = "Luigi"; | ||
const textArea = screen.getByLabelText(/Enter name:/); | ||
fireEvent.change(textArea, { target: { value: name }}); | ||
|
||
const submitButton = screen.getByRole("button"); | ||
fireEvent.click(submitButton); | ||
|
||
const welcomeMessage = screen.getByText(/Welcome Luigi!/i); | ||
expect(welcomeMessage).toBeInTheDocument(); | ||
}) |
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