From 0076f2f82180ac3bb1d6043c378e4b892e29d449 Mon Sep 17 00:00:00 2001 From: fikretellek Date: Wed, 13 Mar 2024 21:45:58 +0000 Subject: [PATCH] tests implemented for CustomerProfile component --- .../CustomerProfile/CustomerProfile.test.jsx | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/components/CustomerProfile/CustomerProfile.test.jsx diff --git a/src/components/CustomerProfile/CustomerProfile.test.jsx b/src/components/CustomerProfile/CustomerProfile.test.jsx new file mode 100644 index 0000000..e104cd3 --- /dev/null +++ b/src/components/CustomerProfile/CustomerProfile.test.jsx @@ -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(); + const profileCard = screen.queryByTestId("profileCard"); + expect(profileCard).toBeNull(); + }); + it("should be displayed after clicking showProfile button", () => { + render(); + 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(); + const showProfileButton = screen.getByTestId("showProfileButton2"); + fireEvent.click(showProfileButton); + const profileCard = screen.getByTestId("profileId"); + expect(profileCard.innerHTML).toBe("Customer Id: 2"); + }); +});