|
1
|
import React from "react" |
|
2
|
import { describe, expect, test, vi } from "vitest" |
|
3
|
import { render } from "@testing-library/react" |
|
4
|
|
|
5
|
// mock components |
|
6
|
vi.mock("@/components/Badge", () => ({ |
|
7
|
Badge: () => <div>Badge</div>, |
|
8
|
})) |
|
9
|
vi.mock("@/components/Card/Layout/Default", () => ({ |
|
10
|
CardDefaultLayout: () => <div>CardDefaultLayout</div>, |
|
11
|
})) |
|
12
|
vi.mock("@/components/Card/Layout/Large", () => ({ |
|
13
|
CardLargeLayout: () => <div>CardLargeLayout</div>, |
|
14
|
})) |
|
15
|
vi.mock("@/components/Card/Layout/Filler", () => ({ |
|
16
|
CardFillerLayout: () => <div>CardFillerLayout</div>, |
|
17
|
})) |
|
18
|
vi.mock("@/components/Card/Layout/Mini", () => ({ |
|
19
|
CardLayoutMini: () => <div>CardLayoutMini</div>, |
|
20
|
})) |
|
21
|
vi.mock("@/components/Card/Layout/Bloom", () => ({ |
|
22
|
CardBloomLayout: () => <div>CardBloomLayout</div>, |
|
23
|
})) |
|
24
|
|
|
25
|
import { Card } from "../../Card" |
|
26
|
|
|
27
|
describe("rendering", () => { |
|
28
|
test("renders default card", () => { |
|
29
|
const { container } = render(<Card>Click me</Card>) |
|
30
|
expect(container).toBeInTheDocument() |
|
31
|
const card = container.querySelector("div") |
|
32
|
expect(card).toBeInTheDocument() |
|
33
|
expect(card).toHaveTextContent("CardDefaultLayout") |
|
34
|
}) |
|
35
|
test("renders large card", () => { |
|
36
|
const { container } = render(<Card type="large">Click me</Card>) |
|
37
|
expect(container).toBeInTheDocument() |
|
38
|
const card = container.querySelector("div") |
|
39
|
expect(card).toBeInTheDocument() |
|
40
|
expect(card).toHaveTextContent("CardLargeLayout") |
|
41
|
}) |
|
42
|
test("renders filler card", () => { |
|
43
|
const { container } = render(<Card type="filler">Click me</Card>) |
|
44
|
expect(container).toBeInTheDocument() |
|
45
|
const card = container.querySelector("div") |
|
46
|
expect(card).toBeInTheDocument() |
|
47
|
expect(card).toHaveTextContent("CardFillerLayout") |
|
48
|
}) |
|
49
|
test("renders mini card", () => { |
|
50
|
const { container } = render(<Card type="mini">Click me</Card>) |
|
51
|
expect(container).toBeInTheDocument() |
|
52
|
const card = container.querySelector("div") |
|
53
|
expect(card).toBeInTheDocument() |
|
54
|
expect(card).toHaveTextContent("CardLayoutMini") |
|
55
|
}) |
|
56
|
test("renders bloom card", () => { |
|
57
|
const { container } = render(<Card type="bloom">Click me</Card>) |
|
58
|
expect(container).toBeInTheDocument() |
|
59
|
const card = container.querySelector("div") |
|
60
|
expect(card).toBeInTheDocument() |
|
61
|
expect(card).toHaveTextContent("CardBloomLayout") |
|
62
|
}) |
|
63
|
}) |