Skip to content

Commit

Permalink
feat: use userEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-hosseini-deriv committed May 10, 2024
1 parent f7d539a commit d5493fe
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from "react";
import { render, fireEvent } from "@testing-library/react";
import { render } from "@testing-library/react";
import Notification from "../Notification";
import userEvent from "@testing-library/user-event";

describe("Notification Component", () => {
it("renders the notification with title, message, and button", () => {
it("renders the notification with title, message, and button", async () => {
const mockAction = jest.fn();
const { getByText, getByRole } = render(
<Notification
Expand All @@ -12,7 +13,7 @@ describe("Notification Component", () => {
message="Test message"
buttonAction={mockAction}
actionText="Click Me"
/>
/>,
);

// Check if the title and message are in the document
Expand All @@ -22,6 +23,6 @@ describe("Notification Component", () => {
// Check if the button is rendered and clickable
const button = getByRole("button", { name: "Click Me" });
await userEvent.click(button);
expect(mockAction).toHaveBeenCalled(); // Ensure button action is triggered
expect(mockAction).toHaveBeenCalled(); // Ensure button action is triggered
});
});
});

0 comments on commit d5493fe

Please sign in to comment.