import { describe, it, expect, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import TasksPage from "./page";

// Mock the TaskList component
vi.mock("@/components/tasks/TaskList", () => ({
  TaskList: ({ tasks, isLoading }: { tasks: unknown[]; isLoading: boolean }): React.JSX.Element => (
    <div data-testid="task-list">{isLoading ? "Loading" : `${String(tasks.length)} tasks`}</div>
  ),
}));

describe("TasksPage", (): void => {
  it("should render the page title", (): void => {
    render(<TasksPage />);
    expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("Tasks");
  });

  it("should render the TaskList component", (): void => {
    render(<TasksPage />);
    expect(screen.getByTestId("task-list")).toBeInTheDocument();
  });

  it("should have proper layout structure", (): void => {
    const { container } = render(<TasksPage />);
    const main = container.querySelector("main");
    expect(main).toBeInTheDocument();
  });
});
