-
Notifications
You must be signed in to change notification settings - Fork 0
/
breadcrumb.test.tsx
100 lines (88 loc) · 2.84 KB
/
breadcrumb.test.tsx
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { render, screen } from "@testing-library/react";
import { createRef } from "react";
import { describe, expect, it } from "vitest";
import {
Breadcrumb,
BreadcrumbEllipsis,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "./breadcrumb";
describe("Breadcrumb", () => {
it("renders without crashing", () => {
render(<Breadcrumb />);
const breadcrumbElement = screen.getByRole("navigation");
expect(breadcrumbElement).toBeInTheDocument();
});
it("forwards ref correctly", () => {
const ref = createRef<HTMLElement>();
render(<Breadcrumb ref={ref} />);
expect(ref.current).not.toBeNull();
});
});
describe("BreadcrumbList", () => {
it("renders without crashing", () => {
render(<BreadcrumbList />);
const breadcrumbListElement = screen.getByRole("list");
expect(breadcrumbListElement).toBeInTheDocument();
});
it("forwards ref correctly", () => {
const ref = createRef<HTMLOListElement>();
render(<BreadcrumbList ref={ref} />);
expect(ref.current).not.toBeNull();
});
});
describe("BreadcrumbItem", () => {
it("renders without crashing", () => {
render(<BreadcrumbItem />);
const breadcrumbItemElement = screen.getByRole("listitem");
expect(breadcrumbItemElement).toBeInTheDocument();
});
it("forwards ref correctly", () => {
const ref = createRef<HTMLLIElement>();
render(<BreadcrumbItem ref={ref} />);
expect(ref.current).not.toBeNull();
});
});
describe("BreadcrumbLink", () => {
it("renders without crashing", () => {
render(<BreadcrumbLink />);
const breadcrumbLinkElement = screen.getByTestId("breadcrumb-link");
expect(breadcrumbLinkElement).toBeInTheDocument();
});
it("forwards ref correctly", () => {
const ref = createRef<HTMLAnchorElement>();
render(<BreadcrumbLink ref={ref} />);
expect(ref.current).not.toBeNull();
});
});
describe("BreadcrumbPage", () => {
it("renders without crashing", () => {
render(<BreadcrumbPage />);
const breadcrumbPageElement = screen.getByRole("link");
expect(breadcrumbPageElement).toBeInTheDocument();
});
it("forwards ref correctly", () => {
const ref = createRef<HTMLLIElement>();
render(<BreadcrumbPage ref={ref} />);
expect(ref.current).not.toBeNull();
});
});
describe("BreadcrumbSeparator", () => {
it("renders without crashing", () => {
render(<BreadcrumbSeparator />);
const breadcrumbSeparatorElement = screen.getByRole("presentation", {
hidden: true,
});
expect(breadcrumbSeparatorElement).toBeInTheDocument();
});
});
describe("BreadcrumbEllipsis", () => {
it("renders without crashing", () => {
render(<BreadcrumbEllipsis />);
const breadcrumbEllipsisElement = screen.getByRole("presentation", { hidden: true });
expect(breadcrumbEllipsisElement).toBeInTheDocument();
});
});