forked from Vero-protocol/vero-core-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerformanceStats.test.tsx
More file actions
45 lines (39 loc) · 1.73 KB
/
Copy pathPerformanceStats.test.tsx
File metadata and controls
45 lines (39 loc) · 1.73 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
41
42
43
44
45
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
import { fireEvent, render, screen } from "@testing-library/react";
import { PerformanceStats } from "./PerformanceStats";
describe("PerformanceStats", () => {
beforeEach(() => {
vi.useFakeTimers();
localStorage.clear();
});
afterEach(() => {
vi.useRealTimers();
});
it("renders the panel title and metric labels", () => {
render(<PerformanceStats />);
expect(screen.getByText(/Network Performance/i)).toBeInTheDocument();
expect(screen.getByText(/Current TPS/i)).toBeInTheDocument();
// The sparkline panel below also mentions "Base fee", so anchor the
// metric-card label to avoid a `getMultipleElementsFound` collision.
expect(screen.getByText(/^Base Fee$/i)).toBeInTheDocument();
});
it("exposes the Pause and Restart buttons", () => {
render(<PerformanceStats />);
expect(screen.getByRole("button", { name: /Pause/i })).toBeInTheDocument();
expect(screen.getByRole("button", { name: /Restart/i })).toBeInTheDocument();
});
it("flips aria-pressed on the Pause/Resume toggle to reflect running state", () => {
render(<PerformanceStats />);
const toggle = screen.getByRole("button", { name: /Pause/i });
expect(toggle.getAttribute("aria-pressed")).toBe("false");
fireEvent.click(toggle);
const resume = screen.getByRole("button", { name: /Resume/i });
expect(resume.getAttribute("aria-pressed")).toBe("true");
});
it("announces running/paused state changes via a screen-reader-only live region", () => {
render(<PerformanceStats />);
const live = document.querySelector('[aria-live="polite"]');
expect(live).not.toBeNull();
expect(live?.textContent).toMatch(/running/i);
});
});