import { describe, expect, it, vi } from "vitest";
import { renderWithProviders } from "../utils/testHelpers";
import { OAuthSigninPage } from "./oauth-signin";

vi.mock("../lib/api", () => ({
  api: {},
}));

describe("OAuthSigninPage", () => {
  beforeEach(() => {
    vi.clearAllMocks();
    localStorage.clear();
    vi.useFakeTimers();
  });

  afterEach(() => {
    vi.useRealTimers();
  });

  it("renders without crashing", () => {
    const { container } = renderWithProviders(<OAuthSigninPage />);
    expect(container).toBeInTheDocument();
  });

  it("clears interval on unmount", () => {
    const { unmount } = renderWithProviders(<OAuthSigninPage />);

    unmount();

    // If interval isn't cleared, this would cause issues
    vi.advanceTimersByTime(150);
  });
});
