|
1
|
import React from "react" |
|
2
|
import { describe, expect, test, vi } from "vitest" |
|
3
|
import { render } from "@testing-library/react" |
|
4
|
|
|
5
|
// mock providers |
|
6
|
vi.mock("@/providers/SiteConfig", () => ({ |
|
7
|
useSiteConfig: () => ({ |
|
8
|
isInProduct: false, |
|
9
|
productView: undefined, |
|
10
|
}), |
|
11
|
})) |
|
12
|
|
|
13
|
// mock components |
|
14
|
vi.mock("@/components/Pagination", () => ({ |
|
15
|
Pagination: () => <div>Pagination</div>, |
|
16
|
})) |
|
17
|
|
|
18
|
import { Footer } from "../../Footer" |
|
19
|
|
|
20
|
describe("rendering", () => { |
|
21
|
test("doesn't render anything by default", () => { |
|
22
|
const { container } = render(<Footer />) |
|
23
|
expect(container).toBeEmptyDOMElement() |
|
24
|
}) |
|
25
|
|
|
26
|
test("renders feedback component when provided", () => { |
|
27
|
const { container } = render( |
|
28
|
<Footer feedbackComponent={<div>Feedback</div>} /> |
|
29
|
) |
|
30
|
expect(container).toContainHTML("<div>Feedback</div>") |
|
31
|
}) |
|
32
|
|
|
33
|
test("renders pagination component when showPagination is true", () => { |
|
34
|
const { container } = render(<Footer showPagination={true} />) |
|
35
|
expect(container).toContainHTML("<div>Pagination</div>") |
|
36
|
}) |
|
37
|
|
|
38
|
test("renders edit component when provided", () => { |
|
39
|
const { container } = render(<Footer editComponent={<div>Edit</div>} />) |
|
40
|
expect(container).toContainHTML("<div>Edit</div>") |
|
41
|
}) |
|
42
|
}) |