-
Notifications
You must be signed in to change notification settings - Fork 1
/
tabs.test.tsx
76 lines (70 loc) · 1.79 KB
/
tabs.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
import { render, screen } from "@testing-library/react";
import { createRef } from "react";
import { describe, expect, it } from "vitest";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./tabs";
describe("TabsList", () => {
it("renders without crashing", () => {
render(
<Tabs>
<TabsList />
</Tabs>,
);
const tabsListElement = screen.getByTestId("tabs-list");
expect(tabsListElement).toBeInTheDocument();
});
it("forwards ref correctly", () => {
const ref = createRef<HTMLDivElement>();
render(
<Tabs>
<TabsList ref={ref} />
</Tabs>,
);
expect(ref.current).not.toBeNull();
});
});
describe("TabsTrigger", () => {
it("renders without crashing", () => {
render(
<Tabs>
<TabsList>
<TabsTrigger value={""}>trigger</TabsTrigger>
</TabsList>
</Tabs>,
);
const tabsTriggerElement = screen.getByRole("tab");
expect(tabsTriggerElement).toBeInTheDocument();
});
it("forwards ref correctly", () => {
const ref = createRef<HTMLButtonElement>();
render(
<Tabs>
<TabsList>
<TabsTrigger ref={ref} value={""}>
trigger
</TabsTrigger>
</TabsList>
</Tabs>,
);
expect(ref.current).not.toBeNull();
});
});
describe("TabsContent", () => {
it("renders without crashing", () => {
render(
<Tabs>
<TabsContent value={""} />
</Tabs>,
);
const tabsContentElement = screen.getByRole("tabpanel", { hidden: true });
expect(tabsContentElement).toBeInTheDocument();
});
it("forwards ref correctly", () => {
const ref = createRef<HTMLDivElement>();
render(
<Tabs>
<TabsContent ref={ref} value={""} />
</Tabs>,
);
expect(ref.current).not.toBeNull();
});
});