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

import { CarouselPromotionsItem } from "../CarouselPromotionsItem";

describe("rendering CarouselPromotionsItem", () => {
  describe("initial state", () => {
    it("has default class carousel-promotions__slide", () => {
      const { getByTestId } = render(
        <CarouselPromotionsItem data-testid="test-id" />,
      );
      expect(getByTestId("test-id")).toHaveClass("carousel-promotions__slide");
    });
  });
  describe("passed props", () => {
    it("renders children", () => {
      const { getByText } = render(
        <CarouselPromotionsItem
          data-testid="test-id"
          title="Akcia za vernosť."
          subtitle="Predĺž si svoj paušál a vyhraj telefón v súťaži."
        />,
      );
      expect(getByText("Akcia za vernosť.")).toBeInTheDocument();
    });
    it("has additional class when className is set", () => {
      const { getByTestId } = render(
        <CarouselPromotionsItem data-testid="test-id" className="test-class" />,
      );
      expect(getByTestId("test-id")).toHaveClass("carousel-promotions__slide");
      expect(getByTestId("test-id")).toHaveClass("test-class");
    });
  });
});
