File size: 1,939 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
// 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 <GenericSliderComponent slidesCount={1} settings={settings} />;
}
function SliderWithUnslick() {
const settings = {
dots: true,
infinite: true,
unslick: true
};
return <GenericSliderComponent slidesCount={2} settings={settings} />;
}
describe("Slider with one slide", function() {
it("should have 1 active slide", function() {
const { container } = render(<SliderWithOneSlide />);
expect(getActiveSlidesCount(container)).toEqual(1);
});
it("should not have any clones", function() {
const { container } = render(<SliderWithOneSlide />);
expect(getClonesCount(container)).toEqual(0);
});
it("should no have dots and arrows", function() {
const { container } = render(<SliderWithOneSlide />);
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(<SliderWithUnslick />);
expect(getActiveSlidesCount(container)).toEqual(1);
});
it("should not have any clones", function() {
const { container } = render(<SliderWithUnslick />);
expect(getClonesCount(container)).toEqual(0);
});
it("should no have dots and arrows", function() {
const { container } = render(<SliderWithUnslick />);
expect(hasArrows(container)).toEqual(false);
expect(hasDots(container)).toEqual(false);
});
});
|