forked from CodeYourFuture/React-Module-Project
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests implemented for CustomerProfile component
- Loading branch information
1 parent
3c5913b
commit 0076f2f
Showing
1 changed file
with
25 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,25 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import Bookings from "../Bookings/Bookings"; | ||
import { fireEvent, render, screen } from "@testing-library/react"; | ||
|
||
describe("Customer Profile card", () => { | ||
it("shouldn't be displayed at the beginning", () => { | ||
render(<Bookings />); | ||
const profileCard = screen.queryByTestId("profileCard"); | ||
expect(profileCard).toBeNull(); | ||
}); | ||
it("should be displayed after clicking showProfile button", () => { | ||
render(<Bookings />); | ||
const showProfileButton = screen.getByTestId("showProfileButton1"); | ||
fireEvent.click(showProfileButton); | ||
const profileCard = screen.getByTestId("profileId"); | ||
expect(profileCard.innerHTML).toBe("Customer Id: 1"); | ||
}); | ||
it("should be displayed after clicking second showProfile button", () => { | ||
render(<Bookings />); | ||
const showProfileButton = screen.getByTestId("showProfileButton2"); | ||
fireEvent.click(showProfileButton); | ||
const profileCard = screen.getByTestId("profileId"); | ||
expect(profileCard.innerHTML).toBe("Customer Id: 2"); | ||
}); | ||
}); |