-
Notifications
You must be signed in to change notification settings - Fork 1
/
card.test.tsx
171 lines (147 loc) · 6.08 KB
/
card.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "./card";
describe("Card", () => {
it("renders without crashing", () => {
render(<Card />);
const cardElement = screen.getByRole("region");
expect(cardElement).toBeInTheDocument();
});
it("applies correct classes", () => {
render(<Card />);
const cardElement = screen.getByRole("region");
expect(cardElement).toHaveClass("rounded-xl border bg-card text-card-foreground");
});
it("correctly applies additional classes", () => {
const additionalClass = "additional-class";
render(<Card className={additionalClass} />);
const cardElement = screen.getByRole("region");
expect(cardElement).toHaveClass("rounded-xl border bg-card text-card-foreground", additionalClass);
});
it("correctly applies additional props", () => {
const testId = "card";
render(<Card data-testid={testId} />);
const cardElement = screen.getByTestId(testId);
expect(cardElement).toBeInTheDocument();
});
});
describe("CardTitle", () => {
it("renders without crashing", () => {
render(<CardTitle />);
const cardTitleElement = screen.getByRole("heading");
expect(cardTitleElement).toBeInTheDocument();
});
it("applies correct classes", () => {
render(<CardTitle />);
const cardTitleElement = screen.getByRole("heading");
expect(cardTitleElement).toHaveClass("font-bold leading-none");
});
it("correctly applies additional classes", () => {
const additionalClass = "additional-class";
render(<CardTitle className={additionalClass} />);
const cardTitleElement = screen.getByRole("heading");
expect(cardTitleElement).toHaveClass("font-bold leading-none", additionalClass);
});
it("correctly applies additional props", () => {
const testId = "card-title";
render(<CardTitle data-testid={testId} />);
const cardTitleElement = screen.getByTestId(testId);
expect(cardTitleElement).toBeInTheDocument();
});
});
describe("CardHeader", () => {
it("renders without crashing", () => {
render(<CardHeader />);
const cardHeaderElement = screen.getByTestId("card-header");
expect(cardHeaderElement).toBeInTheDocument();
});
it("applies correct classes", () => {
render(<CardHeader />);
const cardHeaderElement = screen.getByTestId("card-header");
expect(cardHeaderElement).toHaveClass("flex flex-col space-y-1.5 p-6");
});
it("correctly applies additional classes", () => {
const additionalClass = "additional-class";
render(<CardHeader className={additionalClass} />);
const cardHeaderElement = screen.getByTestId("card-header");
expect(cardHeaderElement).toHaveClass("flex flex-col space-y-1.5 p-6", additionalClass);
});
it("correctly applies additional props", () => {
const testId = "card-header";
render(<CardHeader data-testid={testId} />);
const cardHeaderElement = screen.getByTestId(testId);
expect(cardHeaderElement).toBeInTheDocument();
});
});
describe("CardDescription", () => {
it("renders without crashing", () => {
render(<CardDescription />);
const cardDescriptionElement = screen.getByTestId("card-description");
expect(cardDescriptionElement).toBeInTheDocument();
});
it("applies correct classes", () => {
render(<CardDescription />);
const cardDescriptionElement = screen.getByTestId("card-description");
expect(cardDescriptionElement).toHaveClass("text-muted-foreground text-sm");
});
it("correctly applies additional classes", () => {
const additionalClass = "additional-class";
render(<CardDescription className={additionalClass} />);
const cardDescriptionElement = screen.getByTestId("card-description");
expect(cardDescriptionElement).toHaveClass("text-muted-foreground text-sm", additionalClass);
});
it("correctly applies additional props", () => {
const testId = "card-description";
render(<CardDescription data-testid={testId} />);
const cardDescriptionElement = screen.getByTestId(testId);
expect(cardDescriptionElement).toBeInTheDocument();
});
});
describe("CardContent", () => {
it("renders without crashing", () => {
render(<CardContent />);
const cardContentElement = screen.getByTestId("card-content");
expect(cardContentElement).toBeInTheDocument();
});
it("applies correct classes", () => {
render(<CardContent />);
const cardContentElement = screen.getByTestId("card-content");
expect(cardContentElement).toHaveClass("p-6 pt-0");
});
it("correctly applies additional classes", () => {
const additionalClass = "additional-class";
render(<CardContent className={additionalClass} />);
const cardContentElement = screen.getByTestId("card-content");
expect(cardContentElement).toHaveClass("p-6 pt-0", additionalClass);
});
it("correctly applies additional props", () => {
const testId = "card-content";
render(<CardContent data-testid={testId} />);
const cardContentElement = screen.getByTestId(testId);
expect(cardContentElement).toBeInTheDocument();
});
});
describe("CardFooter", () => {
it("renders without crashing", () => {
render(<CardFooter />);
const cardFooterElement = screen.getByTestId("card-footer");
expect(cardFooterElement).toBeInTheDocument();
});
it("applies correct classes", () => {
render(<CardFooter />);
const cardFooterElement = screen.getByTestId("card-footer");
expect(cardFooterElement).toHaveClass("flex items-center p-6 pt-0");
});
it("correctly applies additional classes", () => {
const additionalClass = "additional-class";
render(<CardFooter className={additionalClass} />);
const cardFooterElement = screen.getByTestId("card-footer");
expect(cardFooterElement).toHaveClass("flex items-center p-6 pt-0", additionalClass);
});
it("correctly applies additional props", () => {
const testId = "card-footer";
render(<CardFooter data-testid={testId} />);
const cardFooterElement = screen.getByTestId(testId);
expect(cardFooterElement).toBeInTheDocument();
});
});