Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds the PromoBar component and a new custom hook useNotificationMessage to the PatronPage #606

Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/tests/unit/notification-message.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import React from "react";
import { cleanup, fireEvent, render } from "@testing-library/react";
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { useNotificationMessage } from "../../core/utils/useNotificationMessage";

// Define a test component that utilizes the useNotificationMessage hook
Expand Down Expand Up @@ -30,6 +30,9 @@ describe("useNotificationMessage hook", () => {
const { getByTestId } = render(<ComponentWithNotificationMessage />);
const wrapper = getByTestId("wrapper");

// Expectations before the button is clicked
expect(screen.queryByText(/Some message/)).toBeNull(); // Expect the message to not be displayed
kasperbirch1 marked this conversation as resolved.
Show resolved Hide resolved

// Assert that the wrapper does not contain the message initially
expect(wrapper).toMatchInlineSnapshot(`
<div
Expand Down Expand Up @@ -59,7 +62,7 @@ describe("useNotificationMessage hook", () => {
// Expectations after the button is clicked
expect(window.scrollTo).toHaveBeenCalledWith(0, 0); // Expect page to scroll to top
expect(window.setTimeout).toHaveBeenCalledTimes(1); // Expect setTimeout to be called once
expect(wrapper.textContent).toMatch(/Some message/); // Expect the message to be displayed
expect(screen.queryByText(/Some message/)).toBeTruthy(); // Expect the message to be displayed

// Assert final state of the wrapper
expect(wrapper).toMatchInlineSnapshot(`
Expand Down
Loading