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

describe("CustomLoadingOverlay", () => {
  it("renders without crashing", () => {
    render(<CustomLoadingOverlay />);
    expect(screen.getByRole("presentation")).toBeInTheDocument();
  });

  it("displays default loading message", () => {
    render(<CustomLoadingOverlay />);
    expect(screen.getByText("Loading...")).toBeInTheDocument();
  });

  it("displays custom loading message", () => {
    render(<CustomLoadingOverlay loadingMessage="Please wait..." />);
    expect(screen.getByText("Please wait...")).toBeInTheDocument();
  });

  it("displays loading icon", () => {
    render(<CustomLoadingOverlay />);
    const icon = screen.getByAltText("Loading icon");
    expect(icon).toBeInTheDocument();
    expect(icon).toHaveAttribute("src", "/icon.jpg");
  });

  it("has spinning animation on icon", () => {
    render(<CustomLoadingOverlay />);
    const icon = screen.getByAltText("Loading icon");
    expect(icon).toHaveClass("animate-spin");
  });
});
