forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotificationBell.test.tsx
More file actions
40 lines (34 loc) · 1.38 KB
/
Copy pathNotificationBell.test.tsx
File metadata and controls
40 lines (34 loc) · 1.38 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
38
39
40
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 { NotificationBell } from "./NotificationBell";
import { resetNotificationsForTesting } from "../../test-utils/notifications";
const wrap = (ui: ReactElement) =>
render(<MemoryRouter>{ui}</MemoryRouter>);
describe("NotificationBell", () => {
beforeEach(() => {
resetNotificationsForTesting();
});
it("renders bell icon", () => {
wrap(<NotificationBell />);
const bell = screen.getByTestId("notification-bell");
expect(bell).toBeInTheDocument();
});
it("shows badge count when there are unread notifications", () => {
wrap(<NotificationBell />);
const badge = screen.getByTestId("notification-badge");
expect(badge).toBeInTheDocument();
expect(Number(badge.textContent)).toBeGreaterThan(0);
});
it("opens dropdown when bell is clicked", () => {
wrap(<NotificationBell />);
fireEvent.click(screen.getByTestId("notification-bell"));
expect(screen.getByTestId("notification-dropdown")).toBeInTheDocument();
});
it("dropdown shows notification list", () => {
wrap(<NotificationBell />);
fireEvent.click(screen.getByTestId("notification-bell"));
expect(screen.getByText("Notifications")).toBeInTheDocument();
});
});