//Test fix of #1813: In infinite mode, when slidesToShow equal to the length of slides, infinite functionality is not working. // Reversed the fix for #1813 to match the slick carousel functionality. When slides <= slidesToShow, unslick will be activated import React from "react"; import { render, fireEvent } from "@testing-library/react"; import { clickNext, clickPrevious, getActiveButton, getActiveSlidesCount, getActiveSlidesText, getButtons, getButtonsLength, getClonesCount, getCurrentSlide, getSlidesCount, hasArrows, hasDots } from "../../test-utils"; import { GenericSliderComponent } from "../TestComponents"; function MultipleItems() { const settings = { dots: true, infinite: true, speed: 500, slidesToShow: 9, slidesToScroll: 3 }; return ; } describe("Multiple Items with slidesToShow = slides count in infinite mode", function() { it("should have 9 active slides", function() { const { container } = render(); expect(getActiveSlidesCount(container)).toEqual(9); }); it("should show first 9 slides", function() { const { container } = render(); //expect(getActiveButton(container)).toEqual(["1"]); expect(getActiveSlidesText(container)).toEqual([ "1", "2", "3", "4", "5", "6", "7", "8", "9" ]); }); it("shouldn't have any arrows", () => { const { container } = render(); expect(hasArrows(container)).toEqual(false); }); it("shouldn't have any dots", () => { const { container } = render(); expect(hasDots(container)).toEqual(false); }); // it("should have 0 dots", function() { // const { container } = render(); // expect(getButtonsLength(container)).toEqual(0); // }); // it("should show slides from 4 when next button is clicked", function() { // const { container } = render(); // clickNext(container); // expect(getActiveButton(container)).toEqual(["2"]); // expect(getActiveSlidesText(container)).toEqual([ // "4", // "5", // "6", // "7", // "8", // "9", // "1", // "2", // "3" // ]); // }); // it("should show slides from 7 when previous button is clicked", function() { // const { container } = render(); // clickPrevious(container); // expect(getActiveButton(container)).toEqual(["3"]); // expect(getActiveSlidesText(container)).toEqual([ // "7", // "8", // "9", // "1", // "2", // "3", // "4", // "5", // "6" // ]); // }); // it("should show slides first 9 slides when first dot is clicked", function() { // const { container } = render(); // fireEvent( // getButtons(container)[0], // new MouseEvent("click", { // bubbles: true, // cancelable: true // }) // ); // expect(getActiveButton(container)).toEqual(["1"]); // expect(getActiveSlidesText(container)).toEqual([ // "1", // "2", // "3", // "4", // "5", // "6", // "7", // "8", // "9" // ]); // }); // it("should show slides from 4 when middle dot is clicked", function() { // const { container } = render(); // fireEvent( // getButtons(container)[1], // new MouseEvent("click", { // bubbles: true, // cancelable: true // }) // ); // expect(getActiveButton(container)).toEqual(["2"]); // expect(getActiveSlidesText(container)).toEqual([ // "4", // "5", // "6", // "7", // "8", // "9", // "1", // "2", // "3" // ]); // }); // it("should show slides from 7 when last dot is clicked", function() { // const { container } = render(); // fireEvent( // getButtons(container)[2], // new MouseEvent("click", { // bubbles: true, // cancelable: true // }) // ); // expect(getActiveButton(container)).toEqual(["3"]); // expect(getActiveSlidesText(container)).toEqual([ // "7", // "8", // "9", // "1", // "2", // "3", // "4", // "5", // "6" // ]); // }); });