Skip to content

Commit

Permalink
tests implemented for CustomerProfile component
Browse files Browse the repository at this point in the history
  • Loading branch information
fikretellek committed Mar 13, 2024
1 parent 3c5913b commit 0076f2f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/components/CustomerProfile/CustomerProfile.test.jsx
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");
});
});

0 comments on commit 0076f2f

Please sign in to comment.