// Test fix of #2414: Extra clones in infinite mode when there is only one slide or unslick is true import React from "react"; import { render, fireEvent } from "@testing-library/react"; import { getCurrentSlideContent, getSlidesCount, getActiveSlidesCount, getClonesCount, hasArrows, hasDots } from "../../test-utils"; import { GenericSliderComponent } from "../TestComponents"; function SliderWithOneSlide() { const settings = { dots: true, infinite: true }; return ; } function SliderWithUnslick() { const settings = { dots: true, infinite: true, unslick: true }; return ; } describe("Slider with one slide", function() { it("should have 1 active slide", function() { const { container } = render(); expect(getActiveSlidesCount(container)).toEqual(1); }); it("should not have any clones", function() { const { container } = render(); expect(getClonesCount(container)).toEqual(0); }); it("should no have dots and arrows", function() { const { container } = render(); expect(hasArrows(container)).toEqual(false); expect(hasDots(container)).toEqual(false); }); }); describe("Slider with unslick=true", function() { it("should have one active slide", function() { const { container } = render(); expect(getActiveSlidesCount(container)).toEqual(1); }); it("should not have any clones", function() { const { container } = render(); expect(getClonesCount(container)).toEqual(0); }); it("should no have dots and arrows", function() { const { container } = render(); expect(hasArrows(container)).toEqual(false); expect(hasDots(container)).toEqual(false); }); });