Skip to content

Commit 5fa447e

Browse files
Merge pull request #19 from ThamannaHarish/complaient
Complaient
2 parents 2d88140 + 854d9fe commit 5fa447e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+9299
-11092
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`BottomNavBar Component matches snapshot 1`] = `
4+
<DocumentFragment>
5+
<nav
6+
class="fixed left-6 right-6 bottom-8 border-t border-gray-300 bg-[var(--main)] text-foreground rounded-2xl"
7+
>
8+
<ul
9+
class="flex items-center justify-around py-2"
10+
>
11+
<li
12+
class="flex flex-col items-center"
13+
>
14+
<button
15+
class="focus:outline-none"
16+
type="button"
17+
>
18+
<div
19+
data-testid="home-icon"
20+
/>
21+
</button>
22+
</li>
23+
<li
24+
class="flex flex-col items-center"
25+
>
26+
<button
27+
class="focus:outline-none"
28+
type="button"
29+
>
30+
<div
31+
data-testid="book-icon"
32+
/>
33+
</button>
34+
</li>
35+
<li
36+
class="flex flex-col items-center"
37+
>
38+
<button
39+
class="focus:outline-none"
40+
type="button"
41+
>
42+
<div
43+
data-testid="calendar-icon"
44+
/>
45+
</button>
46+
</li>
47+
<li
48+
class="flex flex-col items-center"
49+
>
50+
<button
51+
class="focus:outline-none"
52+
type="button"
53+
>
54+
<div
55+
data-testid="money-icon"
56+
/>
57+
</button>
58+
</li>
59+
</ul>
60+
</nav>
61+
</DocumentFragment>
62+
`;

__test__/bottomnavbar.test.tsx

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { render, screen } from "@testing-library/react";
2+
import BottomNavBar from "@/components/bottomNavbar";
3+
import { Book, Calendar2, Home2, Money } from "iconsax-react";
4+
5+
// Mock the icons to verify they're rendered
6+
jest.mock("iconsax-react", () => ({
7+
Book: jest.fn(() => <div data-testid="book-icon" />),
8+
Calendar2: jest.fn(() => <div data-testid="calendar-icon" />),
9+
Home2: jest.fn(() => <div data-testid="home-icon" />),
10+
Money: jest.fn(() => <div data-testid="money-icon" />),
11+
}));
12+
13+
describe("BottomNavBar Component", () => {
14+
beforeEach(() => {
15+
jest.clearAllMocks();
16+
});
17+
18+
it("renders without crashing", () => {
19+
render(<BottomNavBar />);
20+
expect(screen.getByRole("navigation")).toBeInTheDocument();
21+
});
22+
23+
it("has correct styling classes", () => {
24+
render(<BottomNavBar />);
25+
const nav = screen.getByRole("navigation");
26+
27+
expect(nav).toHaveClass("fixed");
28+
expect(nav).toHaveClass("bottom-8");
29+
expect(nav).toHaveClass("rounded-2xl");
30+
expect(nav).toHaveClass("bg-[var(--main)]");
31+
});
32+
33+
it("renders all navigation items", () => {
34+
render(<BottomNavBar />);
35+
36+
const listItems = screen.getAllByRole("listitem");
37+
expect(listItems).toHaveLength(4);
38+
39+
const buttons = screen.getAllByRole("button");
40+
expect(buttons).toHaveLength(4);
41+
});
42+
43+
it("renders correct icons for each nav item", () => {
44+
render(<BottomNavBar />);
45+
46+
expect(Home2).toHaveBeenCalled();
47+
expect(Book).toHaveBeenCalled();
48+
expect(Calendar2).toHaveBeenCalled();
49+
expect(Money).toHaveBeenCalled();
50+
51+
// Verify icon props
52+
const homeIconProps = (Home2 as jest.Mock).mock.calls[0][0];
53+
expect(homeIconProps.size).toBe("32");
54+
expect(homeIconProps.color).toBe("var(--text)");
55+
});
56+
57+
it("has accessible buttons", () => {
58+
render(<BottomNavBar />);
59+
60+
const buttons = screen.getAllByRole("button");
61+
buttons.forEach((button) => {
62+
expect(button).toHaveAttribute("type", "button");
63+
expect(button).toHaveClass("focus:outline-none");
64+
});
65+
});
66+
67+
it("matches snapshot", () => {
68+
const { asFragment } = render(<BottomNavBar />);
69+
expect(asFragment()).toMatchSnapshot();
70+
});
71+
});

__test__/home.test.tsx

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { render, screen } from "@testing-library/react";
2+
import "@testing-library/jest-dom";
3+
import ResponsiveDashboard from "@/components/home/ResponsiveDashboard";
4+
5+
describe("ResponsiveDashboard", () => {
6+
beforeEach(() => {
7+
jest.clearAllMocks();
8+
});
9+
10+
it("renders without crashing", () => {
11+
render(<ResponsiveDashboard />);
12+
expect(screen.getByTestId("quick-actions")).toBeInTheDocument();
13+
expect(screen.getByTestId("timetable-block")).toBeInTheDocument();
14+
});
15+
16+
it("has correct layout structure", () => {
17+
const { container } = render(<ResponsiveDashboard />);
18+
19+
// Check main container classes
20+
const mainContainer = container.querySelector(".min-h-screen");
21+
expect(mainContainer).toBeInTheDocument();
22+
23+
// Check max-width container
24+
const maxWidthContainer = container.querySelector(".max-w-7xl");
25+
expect(maxWidthContainer).toBeInTheDocument();
26+
27+
// Check flex container for md screens
28+
const flexContainer = container.querySelector(".md\\:flex");
29+
expect(flexContainer).toBeInTheDocument();
30+
});
31+
32+
it("applies responsive classes correctly", () => {
33+
const { container } = render(<ResponsiveDashboard />);
34+
35+
// Check section has responsive height classes
36+
const section = container.querySelector("section");
37+
expect(section).toHaveClass(
38+
"h-[64vh]",
39+
"sm:h-[55vh]",
40+
"md:h-full",
41+
"md:w-1/2",
42+
);
43+
});
44+
45+
it("renders both child components", () => {
46+
render(<ResponsiveDashboard />);
47+
48+
// Verify both components are rendered
49+
expect(screen.getByTestId("quick-actions")).toBeInTheDocument();
50+
expect(screen.getByTestId("timetable-block")).toBeInTheDocument();
51+
});
52+
53+
it("has proper semantic HTML structure", () => {
54+
const { container } = render(<ResponsiveDashboard />);
55+
56+
// Check for semantic elements
57+
const main = container.querySelector("main");
58+
const section = container.querySelector("section");
59+
60+
expect(main).toBeInTheDocument();
61+
expect(section).toBeInTheDocument();
62+
});
63+
});

0 commit comments

Comments
 (0)