Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

1.5 KB
Raw Blame
import JobsAppliedCard from "@/components/dashboard/JobsAppliedCard";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { useRouter } from "next/navigation";

vi.mock("next/navigation", () => ({
  useRouter: vi.fn(),
}));

describe("JobsAppliedCard", () => {
  const mockPush = vi.fn();

  beforeEach(() => {
    vi.clearAllMocks();
    (useRouter as any).mockReturnValue({ push: mockPush });
  });

  it("should navigate to myjobs with add-job=true when Job button is clicked", async () => {
    const user = userEvent.setup();
    render(<JobsAppliedCard />);

    await user.click(screen.getByRole("button", { name: /^add job$/i }));

    expect(mockPush).toHaveBeenCalledWith("/dashboard/myjobs?add-job=true");
  });

  it("should navigate to tasks page with add-task=true when Task button is clicked", async () => {
    const user = userEvent.setup();
    render(<JobsAppliedCard />);

    await user.click(screen.getByRole("button", { name: /^add task$/i }));

    expect(mockPush).toHaveBeenCalledWith("/dashboard/tasks?add-task=true");
  });

  it("should navigate to activities page with add-activity=true when Activity button is clicked", async () => {
    const user = userEvent.setup();
    render(<JobsAppliedCard />);

    await user.click(screen.getByRole("button", { name: /^add activity$/i }));

    expect(mockPush).toHaveBeenCalledWith(
      "/dashboard/activities?add-activity=true",
    );
  });
});