Skip to content

Commit 9568a8d

Browse files
committed
Add tests for PrivacyPolicy component
- Created a new test file for the PrivacyPolicy component. - Added tests to verify rendering of main content, navigation links, article element, section headings, and DPO contact email link.
1 parent 7e93372 commit 9568a8d

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { render, screen } from "@testing-library/react";
2+
import "@testing-library/jest-dom";
3+
import { MemoryRouter } from "react-router-dom";
4+
import { describe, expect, test } from "vitest";
5+
import "../../test-utils/CommonMocks.ts";
6+
7+
import PrivacyPolicy from "./PrivacyPolicy";
8+
9+
const setup = () =>
10+
render(
11+
<MemoryRouter>
12+
<PrivacyPolicy />
13+
</MemoryRouter>,
14+
);
15+
16+
describe("PrivacyPolicy", () => {
17+
test("renders main content area", () => {
18+
setup();
19+
expect(screen.getByRole("main")).toBeInTheDocument();
20+
});
21+
22+
test("renders breadcrumb nav with back-to-home link", () => {
23+
setup();
24+
const nav = screen.getByRole("navigation", { name: /breadcrumb/i });
25+
expect(nav).toBeInTheDocument();
26+
27+
const homeLink = screen.getByRole("link", { name: /back to home/i });
28+
expect(homeLink).toBeInTheDocument();
29+
expect(homeLink).toHaveAttribute("href", "/");
30+
});
31+
32+
test("renders the privacy policy article element", () => {
33+
setup();
34+
const article = document.querySelector("article.privacy-policy-content");
35+
expect(article).toBeInTheDocument();
36+
});
37+
38+
test("renders key privacy policy section headings", () => {
39+
setup();
40+
expect(
41+
screen.getAllByText(/WHAT INFORMATION DO WE COLLECT/i).length,
42+
).toBeGreaterThan(0);
43+
expect(
44+
screen.getAllByText(/HOW DO WE PROCESS YOUR INFORMATION/i).length,
45+
).toBeGreaterThan(0);
46+
expect(
47+
screen.getAllByText(/HOW CAN YOU CONTACT US ABOUT THIS NOTICE/i).length,
48+
).toBeGreaterThan(0);
49+
});
50+
51+
test("renders DPO contact email link", () => {
52+
setup();
53+
const emailLinks = screen.getAllByRole("link", {
54+
name: /dpo@webuddhist\.com/i,
55+
});
56+
expect(emailLinks.length).toBeGreaterThan(0);
57+
expect(emailLinks[0]).toHaveAttribute("href", "mailto:dpo@webuddhist.com");
58+
});
59+
});

0 commit comments

Comments
 (0)