File size: 4,438 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//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 <GenericSliderComponent slidesCount={9} settings={settings} />;
}

describe("Multiple Items with slidesToShow = slides count in infinite mode", function() {
  it("should have 9 active slides", function() {
    const { container } = render(<MultipleItems />);
    expect(getActiveSlidesCount(container)).toEqual(9);
  });
  it("should show first 9 slides", function() {
    const { container } = render(<MultipleItems />);
    //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(<MultipleItems />);
    expect(hasArrows(container)).toEqual(false);
  });
  it("shouldn't have any dots", () => {
    const { container } = render(<MultipleItems />);
    expect(hasDots(container)).toEqual(false);
  });
  // it("should have 0 dots", function() {
  //   const { container } = render(<MultipleItems />);
  //   expect(getButtonsLength(container)).toEqual(0);
  // });
  // it("should show slides from 4 when next button is clicked", function() {
  //   const { container } = render(<MultipleItems />);
  //   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(<MultipleItems />);
  //   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(<MultipleItems />);
  //   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(<MultipleItems />);
  //   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(<MultipleItems />);
  //   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"
  //   ]);
  // });
});