import { render } from "@testing-library/react";

import { LoaderFullscreen } from "../";

describe("LoaderFullscreen", () => {
  describe("initial state", () => {
    it("has default class loader-fullscreen", () => {
      const { getByTestId } = render(
        <LoaderFullscreen data-testid="test-id" />,
      );
      expect(getByTestId("test-id")).toHaveClass("loader-fullscreen");
    });

    it("renders a Loader inside", () => {
      const { container } = render(<LoaderFullscreen />);
      expect(container.getElementsByClassName("loader").length).toBe(1);
    });

    it("renders a large Loader by default", () => {
      const { container } = render(<LoaderFullscreen />);
      expect(container.getElementsByClassName("loader--large").length).toBe(1);
    });

    it("has role status", () => {
      const { getByTestId } = render(
        <LoaderFullscreen data-testid="test-id" />,
      );
      expect(getByTestId("test-id")).toHaveAttribute("role", "status");
    });
  });

  describe("passed props", () => {
    it("has additional class when className is set", () => {
      const { getByTestId } = render(
        <LoaderFullscreen data-testid="test-id" className="test-class" />,
      );
      expect(getByTestId("test-id")).toHaveClass("loader-fullscreen");
      expect(getByTestId("test-id")).toHaveClass("test-class");
    });
  });
});
