forked from Liquifact/Liquifact-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvoiceListSkeleton.test.jsx
More file actions
60 lines (50 loc) · 1.95 KB
/
Copy pathInvoiceListSkeleton.test.jsx
File metadata and controls
60 lines (50 loc) · 1.95 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* @file components/InvoiceListSkeleton.test.jsx
* Keeps the skeleton test suite green after the column-width sync refactor.
*/
import React from "react";
import { render, screen } from "@testing-library/react";
import { axe, toHaveNoViolations } from "jest-axe";
import InvoiceListSkeleton from "./InvoiceListSkeleton";
expect.extend(toHaveNoViolations);
describe("InvoiceListSkeleton", () => {
it("renders the default number of rows (3)", () => {
render(<InvoiceListSkeleton />);
const rows = document.querySelectorAll(".animate-pulse");
expect(rows).toHaveLength(3);
});
it("renders a custom number of rows", () => {
render(<InvoiceListSkeleton rows={5} />);
const rows = document.querySelectorAll(".animate-pulse");
expect(rows).toHaveLength(5);
});
it("has an sr-only loading message for screen readers", () => {
render(<InvoiceListSkeleton />);
expect(screen.getByText(/loading invoices, please wait/i)).toBeInTheDocument();
});
it("has no axe accessibility violations", async () => {
const { container } = render(<InvoiceListSkeleton />);
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it("has aria-busy true", () => {
render(<InvoiceListSkeleton />);
expect(screen.getByRole("list")).toHaveAttribute("aria-busy", "true");
});
it("has descriptive aria-label", () => {
render(<InvoiceListSkeleton />);
expect(screen.getByRole("list")).toHaveAttribute("aria-label", "Loading investable invoices");
});
it("each row has animate-pulse class", () => {
render(<InvoiceListSkeleton rows={2} />);
const items = document.querySelectorAll("li");
expect(items).toHaveLength(2);
items.forEach((item) => {
expect(item.className).toContain("animate-pulse");
});
});
it("renders the correct number of skeleton rows", () => {
render(<InvoiceListSkeleton rows={4} />);
expect(document.querySelectorAll("li")).toHaveLength(4);
});
});