From d5493fe7f5e56da235c125c81062f6d5af10534e Mon Sep 17 00:00:00 2001 From: "Ali(Ako) Hosseini" Date: Fri, 10 May 2024 14:01:31 +0800 Subject: [PATCH] feat: use userEvent --- .../Notifications/__test__/notification.spec.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/AppLayout/Notifications/__test__/notification.spec.tsx b/src/components/AppLayout/Notifications/__test__/notification.spec.tsx index cc19e47f..43626bf9 100644 --- a/src/components/AppLayout/Notifications/__test__/notification.spec.tsx +++ b/src/components/AppLayout/Notifications/__test__/notification.spec.tsx @@ -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( { message="Test message" buttonAction={mockAction} actionText="Click Me" - /> + />, ); // Check if the title and message are in the document @@ -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 }); -}); \ No newline at end of file +});