Skip to content

Commit 2f00c93

Browse files
committed
testing done finally
1 parent 7ca3879 commit 2f00c93

3 files changed

Lines changed: 64 additions & 1 deletion

File tree

__tests__/Interview.test.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { render, screen } from "@testing-library/react";
2+
import MeetingPage from "@/app/interview/[slug]/page"; // adjust path if needed
3+
import { useParams } from "next/navigation";
4+
5+
jest.mock("next/navigation", () => ({
6+
useParams: jest.fn(),
7+
}));
8+
9+
jest.mock("@jitsi/react-sdk", () => ({
10+
JitsiMeeting: ({ roomName }: { roomName: string }) => (
11+
<div data-testid="jitsi-meeting">Meeting Room: {roomName}</div>
12+
),
13+
}));
14+
15+
describe("MeetingPage", () => {
16+
it("renders error if no room is provided", () => {
17+
(useParams as jest.Mock).mockReturnValue({});
18+
render(<MeetingPage />);
19+
20+
expect(screen.getByText("Error")).toBeInTheDocument();
21+
22+
});
23+
24+
it("renders JitsiMeeting if room is present", () => {
25+
(useParams as jest.Mock).mockReturnValue({ slug: "room-123" });
26+
render(<MeetingPage />);
27+
28+
expect(screen.getByTestId("jitsi-meeting")).toHaveTextContent("room-123");
29+
});
30+
});

__tests__/Navbar.test.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { render, screen, fireEvent } from "@testing-library/react";
2+
import Navbar from "@/Components/Navbar";
3+
import React from "react";
4+
5+
describe("Navbar Component", () => {
6+
beforeEach(() => {
7+
localStorage.clear();
8+
jest.clearAllMocks();
9+
});
10+
11+
it("renders tabs and sets active tab on click", () => {
12+
const setActiveTab = jest.fn();
13+
render(<Navbar activeTab="internships" setActiveTab={setActiveTab} />);
14+
15+
const internshipsTab = screen.getByText("Internships");
16+
const scholarshipsTab = screen.getByText("Scholarships");
17+
18+
expect(internshipsTab).toBeInTheDocument();
19+
expect(scholarshipsTab).toBeInTheDocument();
20+
21+
fireEvent.click(scholarshipsTab);
22+
expect(setActiveTab).toHaveBeenCalledWith("scholarships");
23+
expect(localStorage.getItem("activeTab")).toBe("scholarships");
24+
});
25+
26+
it("restores active tab from localStorage on mount", () => {
27+
localStorage.setItem("activeTab", "scholarships");
28+
29+
const setActiveTab = jest.fn();
30+
render(<Navbar activeTab="" setActiveTab={setActiveTab} />);
31+
32+
expect(setActiveTab).toHaveBeenCalledWith("scholarships");
33+
});
34+
});

src/app/internships/page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export default function InternshipsPage() {
1818
duration: [0, 12], // Duration in months
1919
});
2020

21-
const prerequisiteOptions = ["React", "Node.js", "Python", "Java"]; // List of available prerequisites
2221

2322
// Fetch projects based on filters
2423
useEffect(() => {

0 commit comments

Comments
 (0)