Skip to content

Commit cd2adc4

Browse files
committed
test: ✅ update card tests
1 parent 8ca844a commit cd2adc4

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed
Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,42 @@
11
import "@testing-library/jest-dom/extend-expect"
2-
import { render } from "@testing-library/react"
3-
import React from "react"
42

3+
import React from "react"
4+
import { render, screen } from "@testing-library/react"
55
import { Card } from "./Card"
66

7-
describe("Card component", () => {
8-
test("renders properly", () => {
9-
const { getByTestId } = render(<Card />)
10-
expect(getByTestId("card")).toBeInTheDocument()
7+
describe("Card", () => {
8+
// ... existing imports and setup ...
9+
10+
it("renders children correctly", () => {
11+
render(<Card>Test Content</Card>)
12+
expect(screen.getByText("Test Content")).toBeInTheDocument()
1113
})
1214

13-
test("should render a card with all props", () => {
14-
const { getByTestId } = render(
15-
<Card
16-
variant="card"
17-
title="Title"
18-
subtitle="Subtitle"
19-
cover="cover.jpg"
20-
tags={[<div key="tag">Tag</div>]}
21-
users={<div>Users</div>}
22-
orientation="vertical"
23-
actions={[<button key="action">Action</button>]}
24-
stats={[{ icon: <div key="icon">Icon</div>, number: 5 }]}
25-
/>
15+
it("applies custom width and height", () => {
16+
render(
17+
<Card width={200} height={100}>
18+
Test Content
19+
</Card>
2620
)
27-
expect(getByTestId("card")).toBeInTheDocument()
21+
const cardContainer = screen.getByText("Test Content").closest("div")
22+
expect(cardContainer).toHaveStyle({ width: "200px", height: "100px" })
23+
})
24+
25+
it("applies default width and height when not provided", () => {
26+
render(<Card>Test Content</Card>)
27+
const cardContainer = screen.getByText("Test Content").closest("div")
28+
expect(cardContainer).toHaveStyle({ width: "40vw", height: "inherit" })
29+
})
30+
31+
it("applies alignment class correctly", () => {
32+
render(<Card align="center">Test Content</Card>)
33+
const cardContainer = screen.getByText("Test Content").closest("div")
34+
expect(cardContainer).toHaveClass("items-center")
35+
})
36+
37+
it("applies custom className", () => {
38+
render(<Card className="custom-class">Test Content</Card>)
39+
const cardContainer = screen.getByText("Test Content").closest("div")
40+
expect(cardContainer).toHaveClass("custom-class")
2841
})
2942
})

0 commit comments

Comments
 (0)