forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotificationDropdown.test.tsx
More file actions
37 lines (31 loc) · 1.43 KB
/
Copy pathNotificationDropdown.test.tsx
File metadata and controls
37 lines (31 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import type { ReactElement } from "react";
import { render, screen, fireEvent } from "@testing-library/react";
import { MemoryRouter } from "react-router";
import { describe, it, expect, beforeEach } from "vitest";
import { NotificationDropdown } from "./NotificationDropdown";
import { resetNotificationsForTesting } from "../../test-utils/notifications";
const wrap = (ui: ReactElement) =>
render(<MemoryRouter>{ui}</MemoryRouter>);
describe("NotificationDropdown", () => {
beforeEach(() => {
resetNotificationsForTesting();
});
it("renders dropdown with notifications list", () => {
wrap(<NotificationDropdown />);
expect(screen.getByTestId("notification-dropdown")).toBeInTheDocument();
expect(screen.getByText("Notifications")).toBeInTheDocument();
});
it("shows Mark all as read when there are unread", () => {
wrap(<NotificationDropdown />);
expect(screen.getByRole("button", { name: /mark all as read/i })).toBeInTheDocument();
});
it("mark all as read clears unread state", () => {
wrap(<NotificationDropdown />);
fireEvent.click(screen.getByRole("button", { name: /mark all as read/i }));
expect(screen.queryByRole("button", { name: /mark all as read/i })).not.toBeInTheDocument();
});
it("shows View all notifications when there are many items", () => {
wrap(<NotificationDropdown maxItems={2} />);
expect(screen.getByText("View all notifications")).toBeInTheDocument();
});
});