@salesforce/design-system-react 0.10.50-alpha.1 → 0.10.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/accordion/__tests__/accordion.browser-test.jsx +302 -0
- package/components/alert/__tests__/alert.browser-test.jsx +100 -0
- package/components/app-launcher/__tests__/app-launcher.browser-test.jsx +228 -0
- package/components/app-launcher/__tests__/expandable-section.browser-test.jsx +144 -0
- package/components/app-launcher/__tests__/link.browser-test.jsx +107 -0
- package/components/app-launcher/__tests__/tile.browser-test.jsx +267 -0
- package/components/avatar/__tests__/avatar.browser-test.jsx +207 -0
- package/components/builder-header/__tests__/builder-header.browser-test.jsx +53 -0
- package/components/button/__tests__/button.browser-test.jsx +226 -0
- package/components/button-group/__tests__/button-group.browser-test.jsx +144 -0
- package/components/button-stateful/__tests__/button-stateful.browser-test.jsx +125 -0
- package/components/card/__tests__/card.browser-test.jsx +255 -0
- package/components/carousel/__tests__/carousel.browser-test.jsx +527 -0
- package/components/color-picker/__tests__/color-picker.browser-test.jsx +767 -0
- package/components/combobox/__tests__/combobox.browser-test.jsx +654 -0
- package/components/data-table/__tests__/data-table.browser-test.jsx +1051 -0
- package/components/date-picker/__tests__/__snapshots__/datepicker.dom-snapshot-test.jsx.snap +4429 -0
- package/components/date-picker/__tests__/date-picker.browser-test.jsx +497 -0
- package/components/date-picker/__tests__/datepicker.dom-snapshot-test.jsx +109 -0
- package/components/docked-composer/__tests__/docked-composer.browser-test.jsx +83 -0
- package/components/expandable-section/__tests__/expandable-section.browser-test.jsx +133 -0
- package/components/expression/__tests__/expression.browser-test.jsx +255 -0
- package/components/filter/__tests__/filter.browser-test.jsx +147 -0
- package/components/forms/input/__tests__/inline.browser-test.jsx +164 -0
- package/components/global-header/__tests__/global-header.browser-test.jsx +177 -0
- package/components/global-navigation-bar/__tests__/global-navigation-bar.browser-test.jsx +464 -0
- package/components/icon/__tests__/icon.browser-test.jsx +214 -0
- package/components/illustration/__tests__/illustration.browser-test.jsx +177 -0
- package/components/input/__tests__/input.browser-test.jsx +612 -0
- package/components/location-map/__tests__/location-map.browser-test.jsx +158 -0
- package/components/lookup/__tests__/lookup.browser-test.jsx +353 -0
- package/components/media-object/__tests__/media-object.browser-test.jsx +87 -0
- package/components/menu-dropdown/__tests__/dropdown.browser-test.jsx +588 -0
- package/components/menu-picklist/__tests__/menupicklist.snapshot-old-test.jsx +41 -0
- package/components/menu-picklist/__tests__/picklist-base.browser-test.jsx +275 -0
- package/components/modal/__tests__/modal.browser-test.jsx +333 -0
- package/components/notification/__tests__/notification.browser-test.jsx +113 -0
- package/components/page-header/__tests__/page-header.browser-test.jsx +161 -0
- package/components/panel/__tests__/__snapshots__/filtering.dom-snapshot-test.jsx.snap +298 -0
- package/components/panel/__tests__/filtering.dom-snapshot-test.jsx +9 -0
- package/components/pill/__tests__/pill.browser-test.jsx +308 -0
- package/components/pill-container/__tests__/pill-container.browser-test.jsx +186 -0
- package/components/popover/__tests__/popover.browser-test.jsx +327 -0
- package/components/progress-indicator/__tests__/progress-indicator.browser-test.jsx +335 -0
- package/components/radio-button-group/__tests__/radio-button-group.browser-test.jsx +122 -0
- package/components/radio-group/__tests__/radio-group.browser-test.jsx +119 -0
- package/components/setup-assistant/__tests__/setup-assistant.browser-test.jsx +77 -0
- package/components/slider/__tests__/slider.browser-test.jsx +389 -0
- package/components/spinner/__tests__/spinner.browser-test.jsx +57 -0
- package/components/split-view/__tests__/split-view.listbox.browser-test.jsx +225 -0
- package/components/split-view/__tests__/split-view.listbox.header.browser-test.jsx +158 -0
- package/components/split-view/__tests__/split-view.listbox.unread.browser-test.jsx +114 -0
- package/components/tabs/__tests__/tabs.browser-test.jsx +458 -0
- package/components/textarea/__tests__/textarea.browser-test.jsx +175 -0
- package/components/time-picker/__tests__/time-picker.browser-test.jsx +46 -0
- package/components/toast/__tests__/toast.browser-test.jsx +118 -0
- package/components/tooltip/__tests__/tooltip.browser-test.jsx +214 -0
- package/components/tree/__tests__/tree.browser-test.jsx +303 -0
- package/components/vertical-navigation/__tests__/navigation.browser-test.jsx +117 -0
- package/components/visual-picker/__tests__/visual-picker.browser-test.jsx +288 -0
- package/components/welcome-mat/__tests__/welcome-mat.browser-test.jsx +358 -0
- package/design-system-react-components.js +1 -1
- package/design-system-react-components.min.js.LICENSE.txt +1 -1
- package/design-system-react.js +1 -1
- package/design-system-react.min.js.LICENSE.txt +1 -1
- package/lib/design-system-react-components.min.js.LICENSE.txt +1 -1
- package/lib/design-system-react.min.js.LICENSE.txt +1 -1
- package/lib/package.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
import { mount } from 'enzyme';
|
|
4
|
+
|
|
5
|
+
import IconSettings from '../../icon-settings';
|
|
6
|
+
import Carousel from '../../carousel';
|
|
7
|
+
|
|
8
|
+
import KEYS from '../../../utilities/key-code';
|
|
9
|
+
|
|
10
|
+
/* eslint-disable react/no-find-dom-node */
|
|
11
|
+
|
|
12
|
+
const items = [
|
|
13
|
+
{
|
|
14
|
+
id: 1,
|
|
15
|
+
heading: 'Visit App Exchange',
|
|
16
|
+
description: 'Extend Salesforce with the #1 business marketplace.',
|
|
17
|
+
imageAssistiveText: 'Appy',
|
|
18
|
+
src: '/assets/images/carousel/carousel-01.jpg',
|
|
19
|
+
href: 'https://www.salesforce.com',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 2,
|
|
23
|
+
heading: 'Click to Customize',
|
|
24
|
+
description:
|
|
25
|
+
'Use the Object Manager to add fields, build layouts, and more.',
|
|
26
|
+
imageAssistiveText: 'Apps',
|
|
27
|
+
src: '/assets/images/carousel/carousel-02.jpg',
|
|
28
|
+
href: 'https://www.salesforce.com',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 3,
|
|
32
|
+
heading: 'Download Salesforce Apps',
|
|
33
|
+
description: "Get the mobile app that's just for Salesforce admins.",
|
|
34
|
+
imageAssistiveText: 'Salesforce Apps',
|
|
35
|
+
src: '/assets/images/carousel/carousel-03.jpg',
|
|
36
|
+
href: 'https://www.salesforce.com',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 4,
|
|
40
|
+
heading: 'Carousel Item 4',
|
|
41
|
+
description: 'Description for carousel item #4',
|
|
42
|
+
imageAssistiveText: 'Apps',
|
|
43
|
+
src: '/assets/images/carousel/carousel-02.jpg',
|
|
44
|
+
href: 'https://www.salesforce.com',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 5,
|
|
48
|
+
heading: 'Carousel Item 5',
|
|
49
|
+
description: 'Description for carousel item #5',
|
|
50
|
+
imageAssistiveText: 'Appy',
|
|
51
|
+
src: '/assets/images/carousel/carousel-01.jpg',
|
|
52
|
+
href: 'https://www.salesforce.com',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 6,
|
|
56
|
+
heading: 'Carousel Item 6',
|
|
57
|
+
description: 'Description for carousel item #6',
|
|
58
|
+
imageAssistiveText: 'Salesforce Apps',
|
|
59
|
+
src: '/assets/images/carousel/carousel-03.jpg',
|
|
60
|
+
href: 'https://www.salesforce.com',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: 7,
|
|
64
|
+
heading: 'Carousel Item 7',
|
|
65
|
+
description: 'Description for carousel item #7',
|
|
66
|
+
imageAssistiveText: 'Apps',
|
|
67
|
+
src: '/assets/images/carousel/carousel-02.jpg',
|
|
68
|
+
href: 'https://www.salesforce.com',
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
describe('SLDS Carousel', () => {
|
|
73
|
+
const handles = {
|
|
74
|
+
carousel: null,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const defaultCarouselProps = {
|
|
78
|
+
hasAutoplay: true,
|
|
79
|
+
hasPreviousNextPanelNavigation: true,
|
|
80
|
+
id: 'test-carousel',
|
|
81
|
+
isInfinite: true,
|
|
82
|
+
items,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const createCarousel = (props) =>
|
|
86
|
+
React.createElement(Carousel, { ...defaultCarouselProps, ...props });
|
|
87
|
+
|
|
88
|
+
function mountCarousel(props) {
|
|
89
|
+
handles.carousel = mount(
|
|
90
|
+
<IconSettings iconPath="/assets/icons">
|
|
91
|
+
{createCarousel(props)}
|
|
92
|
+
</IconSettings>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
describe('Carousel interactions - one item per panel', () => {
|
|
97
|
+
const tabIndexRegex = /tabindex="0"/;
|
|
98
|
+
|
|
99
|
+
beforeEach(() => {
|
|
100
|
+
mountCarousel({
|
|
101
|
+
itemsPerPanel: 1,
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('renders carousel', () => {
|
|
106
|
+
expect(handles.carousel.length).to.equal(1);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('handles autoplay toggle correctly', () => {
|
|
110
|
+
const autoplayButton = handles.carousel.find(
|
|
111
|
+
'.slds-carousel__autoplay button'
|
|
112
|
+
);
|
|
113
|
+
autoplayButton.simulate('click');
|
|
114
|
+
expect(autoplayButton.html().search(/#play/) >= 0).to.eql(true);
|
|
115
|
+
autoplayButton.simulate('click');
|
|
116
|
+
expect(autoplayButton.html().search(/#pause/) >= 0).to.eql(true);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('handles previous button presses correctly', () => {
|
|
120
|
+
const previousButton = handles.carousel
|
|
121
|
+
.find('.slds-is-absolute button.slds-button_icon-border-filled')
|
|
122
|
+
.at(0);
|
|
123
|
+
previousButton.simulate('click');
|
|
124
|
+
expect(
|
|
125
|
+
handles.carousel
|
|
126
|
+
.find(`#content-id-${defaultCarouselProps.id}-7 a`)
|
|
127
|
+
.html()
|
|
128
|
+
.search(tabIndexRegex) >= 0
|
|
129
|
+
).to.eql(true);
|
|
130
|
+
expect(
|
|
131
|
+
handles.carousel
|
|
132
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-6`)
|
|
133
|
+
.html()
|
|
134
|
+
.search(tabIndexRegex) >= 0
|
|
135
|
+
).to.eql(true);
|
|
136
|
+
previousButton.simulate('click');
|
|
137
|
+
expect(
|
|
138
|
+
handles.carousel
|
|
139
|
+
.find(`#content-id-${defaultCarouselProps.id}-6 a`)
|
|
140
|
+
.html()
|
|
141
|
+
.search(tabIndexRegex) >= 0
|
|
142
|
+
).to.eql(true);
|
|
143
|
+
expect(
|
|
144
|
+
handles.carousel
|
|
145
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-5`)
|
|
146
|
+
.html()
|
|
147
|
+
.search(tabIndexRegex) >= 0
|
|
148
|
+
).to.eql(true);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('handles next button presses correctly', () => {
|
|
152
|
+
const nextButton = handles.carousel
|
|
153
|
+
.find('.slds-is-absolute button.slds-button_icon-border-filled')
|
|
154
|
+
.at(1);
|
|
155
|
+
nextButton.simulate('click');
|
|
156
|
+
expect(
|
|
157
|
+
handles.carousel
|
|
158
|
+
.find(`#content-id-${defaultCarouselProps.id}-2 a`)
|
|
159
|
+
.html()
|
|
160
|
+
.search(tabIndexRegex) >= 0
|
|
161
|
+
).to.eql(true);
|
|
162
|
+
expect(
|
|
163
|
+
handles.carousel
|
|
164
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-1`)
|
|
165
|
+
.html()
|
|
166
|
+
.search(tabIndexRegex) >= 0
|
|
167
|
+
).to.eql(true);
|
|
168
|
+
nextButton.simulate('click');
|
|
169
|
+
expect(
|
|
170
|
+
handles.carousel
|
|
171
|
+
.find(`#content-id-${defaultCarouselProps.id}-3 a`)
|
|
172
|
+
.html()
|
|
173
|
+
.search(tabIndexRegex) >= 0
|
|
174
|
+
).to.eql(true);
|
|
175
|
+
expect(
|
|
176
|
+
handles.carousel
|
|
177
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-2`)
|
|
178
|
+
.html()
|
|
179
|
+
.search(tabIndexRegex) >= 0
|
|
180
|
+
).to.eql(true);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('handles keyboard navigation correctly', () => {
|
|
184
|
+
handles.carousel.simulate('focus');
|
|
185
|
+
handles.carousel.simulate('keyDown', { keyCode: KEYS.RIGHT });
|
|
186
|
+
expect(
|
|
187
|
+
handles.carousel
|
|
188
|
+
.find(`#content-id-${defaultCarouselProps.id}-2 a`)
|
|
189
|
+
.html()
|
|
190
|
+
.search(tabIndexRegex) >= 0
|
|
191
|
+
).to.eql(true);
|
|
192
|
+
expect(
|
|
193
|
+
handles.carousel
|
|
194
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-1`)
|
|
195
|
+
.html()
|
|
196
|
+
.search(tabIndexRegex) >= 0
|
|
197
|
+
).to.eql(true);
|
|
198
|
+
handles.carousel.simulate('keyDown', { keyCode: KEYS.LEFT });
|
|
199
|
+
expect(
|
|
200
|
+
handles.carousel
|
|
201
|
+
.find(`#content-id-${defaultCarouselProps.id}-1 a`)
|
|
202
|
+
.html()
|
|
203
|
+
.search(tabIndexRegex) >= 0
|
|
204
|
+
).to.eql(true);
|
|
205
|
+
expect(
|
|
206
|
+
handles.carousel
|
|
207
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-0`)
|
|
208
|
+
.html()
|
|
209
|
+
.search(tabIndexRegex) >= 0
|
|
210
|
+
).to.eql(true);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('handles indicator button presses correctly', () => {
|
|
214
|
+
handles.carousel
|
|
215
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-2`)
|
|
216
|
+
.simulate('click');
|
|
217
|
+
expect(
|
|
218
|
+
handles.carousel
|
|
219
|
+
.find(`#content-id-${defaultCarouselProps.id}-3 a`)
|
|
220
|
+
.html()
|
|
221
|
+
.search(tabIndexRegex) >= 0
|
|
222
|
+
).to.eql(true);
|
|
223
|
+
expect(
|
|
224
|
+
handles.carousel
|
|
225
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-2`)
|
|
226
|
+
.html()
|
|
227
|
+
.search(tabIndexRegex) >= 0
|
|
228
|
+
).to.eql(true);
|
|
229
|
+
handles.carousel
|
|
230
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-6`)
|
|
231
|
+
.simulate('click');
|
|
232
|
+
expect(
|
|
233
|
+
handles.carousel
|
|
234
|
+
.find(`#content-id-${defaultCarouselProps.id}-7 a`)
|
|
235
|
+
.html()
|
|
236
|
+
.search(tabIndexRegex) >= 0
|
|
237
|
+
).to.eql(true);
|
|
238
|
+
expect(
|
|
239
|
+
handles.carousel
|
|
240
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-6`)
|
|
241
|
+
.html()
|
|
242
|
+
.search(tabIndexRegex) >= 0
|
|
243
|
+
).to.eql(true);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
describe('Carousel interactions - three items per panel', () => {
|
|
248
|
+
const tabIndexRegex = /tabindex="0"/;
|
|
249
|
+
|
|
250
|
+
beforeEach(() => {
|
|
251
|
+
mountCarousel({
|
|
252
|
+
itemsPerPanel: 3,
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it('handles previous button presses correctly', () => {
|
|
257
|
+
const previousButton = handles.carousel
|
|
258
|
+
.find('.slds-is-absolute button.slds-button_icon-border-filled')
|
|
259
|
+
.at(0);
|
|
260
|
+
previousButton.simulate('click');
|
|
261
|
+
expect(
|
|
262
|
+
handles.carousel
|
|
263
|
+
.find(`#content-id-${defaultCarouselProps.id}-7 a`)
|
|
264
|
+
.html()
|
|
265
|
+
.search(tabIndexRegex) >= 0
|
|
266
|
+
).to.eql(true);
|
|
267
|
+
previousButton.simulate('click');
|
|
268
|
+
expect(
|
|
269
|
+
handles.carousel
|
|
270
|
+
.find(`#content-id-${defaultCarouselProps.id}-6 a`)
|
|
271
|
+
.html()
|
|
272
|
+
.search(tabIndexRegex) >= 0
|
|
273
|
+
).to.eql(true);
|
|
274
|
+
expect(
|
|
275
|
+
handles.carousel
|
|
276
|
+
.find(`#content-id-${defaultCarouselProps.id}-5 a`)
|
|
277
|
+
.html()
|
|
278
|
+
.search(tabIndexRegex) >= 0
|
|
279
|
+
).to.eql(true);
|
|
280
|
+
expect(
|
|
281
|
+
handles.carousel
|
|
282
|
+
.find(`#content-id-${defaultCarouselProps.id}-4 a`)
|
|
283
|
+
.html()
|
|
284
|
+
.search(tabIndexRegex) >= 0
|
|
285
|
+
).to.eql(true);
|
|
286
|
+
previousButton.simulate('click');
|
|
287
|
+
expect(
|
|
288
|
+
handles.carousel
|
|
289
|
+
.find(`#content-id-${defaultCarouselProps.id}-3 a`)
|
|
290
|
+
.html()
|
|
291
|
+
.search(tabIndexRegex) >= 0
|
|
292
|
+
).to.eql(true);
|
|
293
|
+
expect(
|
|
294
|
+
handles.carousel
|
|
295
|
+
.find(`#content-id-${defaultCarouselProps.id}-2 a`)
|
|
296
|
+
.html()
|
|
297
|
+
.search(tabIndexRegex) >= 0
|
|
298
|
+
).to.eql(true);
|
|
299
|
+
expect(
|
|
300
|
+
handles.carousel
|
|
301
|
+
.find(`#content-id-${defaultCarouselProps.id}-1 a`)
|
|
302
|
+
.html()
|
|
303
|
+
.search(tabIndexRegex) >= 0
|
|
304
|
+
).to.eql(true);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it('handles next button presses correctly', () => {
|
|
308
|
+
const nextButton = handles.carousel
|
|
309
|
+
.find('.slds-is-absolute button.slds-button_icon-border-filled')
|
|
310
|
+
.at(1);
|
|
311
|
+
nextButton.simulate('click');
|
|
312
|
+
expect(
|
|
313
|
+
handles.carousel
|
|
314
|
+
.find(`#content-id-${defaultCarouselProps.id}-4 a`)
|
|
315
|
+
.html()
|
|
316
|
+
.search(tabIndexRegex) >= 0
|
|
317
|
+
).to.eql(true);
|
|
318
|
+
expect(
|
|
319
|
+
handles.carousel
|
|
320
|
+
.find(`#content-id-${defaultCarouselProps.id}-5 a`)
|
|
321
|
+
.html()
|
|
322
|
+
.search(tabIndexRegex) >= 0
|
|
323
|
+
).to.eql(true);
|
|
324
|
+
expect(
|
|
325
|
+
handles.carousel
|
|
326
|
+
.find(`#content-id-${defaultCarouselProps.id}-6 a`)
|
|
327
|
+
.html()
|
|
328
|
+
.search(tabIndexRegex) >= 0
|
|
329
|
+
).to.eql(true);
|
|
330
|
+
expect(
|
|
331
|
+
handles.carousel
|
|
332
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-1`)
|
|
333
|
+
.html()
|
|
334
|
+
.search(tabIndexRegex) >= 0
|
|
335
|
+
).to.eql(true);
|
|
336
|
+
nextButton.simulate('click');
|
|
337
|
+
expect(
|
|
338
|
+
handles.carousel
|
|
339
|
+
.find(`#content-id-${defaultCarouselProps.id}-7 a`)
|
|
340
|
+
.html()
|
|
341
|
+
.search(tabIndexRegex) >= 0
|
|
342
|
+
).to.eql(true);
|
|
343
|
+
expect(
|
|
344
|
+
handles.carousel
|
|
345
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-2`)
|
|
346
|
+
.html()
|
|
347
|
+
.search(tabIndexRegex) >= 0
|
|
348
|
+
).to.eql(true);
|
|
349
|
+
nextButton.simulate('click');
|
|
350
|
+
expect(
|
|
351
|
+
handles.carousel
|
|
352
|
+
.find(`#content-id-${defaultCarouselProps.id}-1 a`)
|
|
353
|
+
.html()
|
|
354
|
+
.search(tabIndexRegex) >= 0
|
|
355
|
+
).to.eql(true);
|
|
356
|
+
expect(
|
|
357
|
+
handles.carousel
|
|
358
|
+
.find(`#content-id-${defaultCarouselProps.id}-2 a`)
|
|
359
|
+
.html()
|
|
360
|
+
.search(tabIndexRegex) >= 0
|
|
361
|
+
).to.eql(true);
|
|
362
|
+
expect(
|
|
363
|
+
handles.carousel
|
|
364
|
+
.find(`#content-id-${defaultCarouselProps.id}-3 a`)
|
|
365
|
+
.html()
|
|
366
|
+
.search(tabIndexRegex) >= 0
|
|
367
|
+
).to.eql(true);
|
|
368
|
+
expect(
|
|
369
|
+
handles.carousel
|
|
370
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-0`)
|
|
371
|
+
.html()
|
|
372
|
+
.search(tabIndexRegex) >= 0
|
|
373
|
+
).to.eql(true);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it('handles keyboard navigation correctly', () => {
|
|
377
|
+
handles.carousel.simulate('focus');
|
|
378
|
+
handles.carousel.simulate('keyDown', { keyCode: KEYS.RIGHT });
|
|
379
|
+
expect(
|
|
380
|
+
handles.carousel
|
|
381
|
+
.find(`#content-id-${defaultCarouselProps.id}-4 a`)
|
|
382
|
+
.html()
|
|
383
|
+
.search(tabIndexRegex) >= 0
|
|
384
|
+
).to.eql(true);
|
|
385
|
+
expect(
|
|
386
|
+
handles.carousel
|
|
387
|
+
.find(`#content-id-${defaultCarouselProps.id}-5 a`)
|
|
388
|
+
.html()
|
|
389
|
+
.search(tabIndexRegex) >= 0
|
|
390
|
+
).to.eql(true);
|
|
391
|
+
expect(
|
|
392
|
+
handles.carousel
|
|
393
|
+
.find(`#content-id-${defaultCarouselProps.id}-6 a`)
|
|
394
|
+
.html()
|
|
395
|
+
.search(tabIndexRegex) >= 0
|
|
396
|
+
).to.eql(true);
|
|
397
|
+
expect(
|
|
398
|
+
handles.carousel
|
|
399
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-1`)
|
|
400
|
+
.html()
|
|
401
|
+
.search(tabIndexRegex) >= 0
|
|
402
|
+
).to.eql(true);
|
|
403
|
+
handles.carousel.simulate('keyDown', { keyCode: KEYS.LEFT });
|
|
404
|
+
expect(
|
|
405
|
+
handles.carousel
|
|
406
|
+
.find(`#content-id-${defaultCarouselProps.id}-1 a`)
|
|
407
|
+
.html()
|
|
408
|
+
.search(tabIndexRegex) >= 0
|
|
409
|
+
).to.eql(true);
|
|
410
|
+
expect(
|
|
411
|
+
handles.carousel
|
|
412
|
+
.find(`#content-id-${defaultCarouselProps.id}-2 a`)
|
|
413
|
+
.html()
|
|
414
|
+
.search(tabIndexRegex) >= 0
|
|
415
|
+
).to.eql(true);
|
|
416
|
+
expect(
|
|
417
|
+
handles.carousel
|
|
418
|
+
.find(`#content-id-${defaultCarouselProps.id}-3 a`)
|
|
419
|
+
.html()
|
|
420
|
+
.search(tabIndexRegex) >= 0
|
|
421
|
+
).to.eql(true);
|
|
422
|
+
expect(
|
|
423
|
+
handles.carousel
|
|
424
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-0`)
|
|
425
|
+
.html()
|
|
426
|
+
.search(tabIndexRegex) >= 0
|
|
427
|
+
).to.eql(true);
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
it('handles indicator button presses correctly', () => {
|
|
431
|
+
handles.carousel
|
|
432
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-2`)
|
|
433
|
+
.simulate('click');
|
|
434
|
+
expect(
|
|
435
|
+
handles.carousel
|
|
436
|
+
.find(`#content-id-${defaultCarouselProps.id}-7 a`)
|
|
437
|
+
.html()
|
|
438
|
+
.search(tabIndexRegex) >= 0
|
|
439
|
+
).to.eql(true);
|
|
440
|
+
expect(
|
|
441
|
+
handles.carousel
|
|
442
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-2`)
|
|
443
|
+
.html()
|
|
444
|
+
.search(tabIndexRegex) >= 0
|
|
445
|
+
).to.eql(true);
|
|
446
|
+
handles.carousel
|
|
447
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-1`)
|
|
448
|
+
.simulate('click');
|
|
449
|
+
expect(
|
|
450
|
+
handles.carousel
|
|
451
|
+
.find(`#content-id-${defaultCarouselProps.id}-4 a`)
|
|
452
|
+
.html()
|
|
453
|
+
.search(tabIndexRegex) >= 0
|
|
454
|
+
).to.eql(true);
|
|
455
|
+
expect(
|
|
456
|
+
handles.carousel
|
|
457
|
+
.find(`#content-id-${defaultCarouselProps.id}-5 a`)
|
|
458
|
+
.html()
|
|
459
|
+
.search(tabIndexRegex) >= 0
|
|
460
|
+
).to.eql(true);
|
|
461
|
+
expect(
|
|
462
|
+
handles.carousel
|
|
463
|
+
.find(`#content-id-${defaultCarouselProps.id}-6 a`)
|
|
464
|
+
.html()
|
|
465
|
+
.search(tabIndexRegex) >= 0
|
|
466
|
+
).to.eql(true);
|
|
467
|
+
expect(
|
|
468
|
+
handles.carousel
|
|
469
|
+
.find(`#indicator-id-${defaultCarouselProps.id}-1`)
|
|
470
|
+
.html()
|
|
471
|
+
.search(tabIndexRegex) >= 0
|
|
472
|
+
).to.eql(true);
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
describe('Carousel events', () => {
|
|
477
|
+
let itemClickObject;
|
|
478
|
+
let requestAutoplayObject;
|
|
479
|
+
let requestPanelChangeObject;
|
|
480
|
+
|
|
481
|
+
beforeEach(() => {
|
|
482
|
+
mountCarousel({
|
|
483
|
+
itemsPerPanel: 1,
|
|
484
|
+
onRequestAutoplayToggle: (event, data) => {
|
|
485
|
+
requestAutoplayObject = { event, data };
|
|
486
|
+
},
|
|
487
|
+
onRequestPanelChange: (event, data) => {
|
|
488
|
+
requestPanelChangeObject = { event, data };
|
|
489
|
+
},
|
|
490
|
+
onItemClick: (event, data) => {
|
|
491
|
+
itemClickObject = { event, data };
|
|
492
|
+
},
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
it('calls onRequestAutoplayToggle correctly', () => {
|
|
497
|
+
handles.carousel
|
|
498
|
+
.find('.slds-carousel__autoplay button')
|
|
499
|
+
.simulate('click');
|
|
500
|
+
expect(requestAutoplayObject !== undefined).to.eql(true);
|
|
501
|
+
expect(typeof requestAutoplayObject.event).to.eql('object');
|
|
502
|
+
expect(typeof requestAutoplayObject.data).to.eql('object');
|
|
503
|
+
expect(requestAutoplayObject.data.isAutoplayOn).to.eql(true);
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
it('calls onRequestPanelChange correctly', () => {
|
|
507
|
+
handles.carousel.simulate('focus');
|
|
508
|
+
handles.carousel.simulate('keyDown', { keyCode: KEYS.RIGHT });
|
|
509
|
+
expect(requestPanelChangeObject !== undefined).to.eql(true);
|
|
510
|
+
expect(typeof requestPanelChangeObject.event).to.eql('object');
|
|
511
|
+
expect(typeof requestPanelChangeObject.data).to.eql('object');
|
|
512
|
+
expect(requestPanelChangeObject.data.currentPanel).to.eql(0);
|
|
513
|
+
expect(requestPanelChangeObject.data.requestedPanel).to.eql(1);
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
it('calls onItemClick correctly', () => {
|
|
517
|
+
handles.carousel
|
|
518
|
+
.find(`#content-id-${defaultCarouselProps.id}-1 a`)
|
|
519
|
+
.simulate('click');
|
|
520
|
+
expect(itemClickObject !== undefined).to.eql(true);
|
|
521
|
+
expect(typeof itemClickObject.event).to.eql('object');
|
|
522
|
+
expect(typeof itemClickObject.data).to.eql('object');
|
|
523
|
+
expect(typeof itemClickObject.data.item).to.eql('object');
|
|
524
|
+
expect(itemClickObject.data.item.id).to.eql(1);
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
});
|