@salesforce/design-system-react 0.10.50-alpha.1 → 0.10.50-alpha.2
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,327 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import chai, { expect } from 'chai';
|
|
5
|
+
import chaiEnzyme from 'chai-enzyme';
|
|
6
|
+
import { mount } from 'enzyme';
|
|
7
|
+
|
|
8
|
+
/* Enzyme Helpers that can mount and unmount React component instances to
|
|
9
|
+
* the DOM and set `this.wrapper` and `this.dom` within Mocha's `this`
|
|
10
|
+
* context [full source here](tests/enzyme-helpers.js). `this` can
|
|
11
|
+
* only be referenced if inside `function () {}`.
|
|
12
|
+
*/
|
|
13
|
+
import {
|
|
14
|
+
createMountNode,
|
|
15
|
+
destroyMountNode,
|
|
16
|
+
} from '../../../tests/enzyme-helpers';
|
|
17
|
+
|
|
18
|
+
// Import your internal dependencies (for example):
|
|
19
|
+
import Popover from '../../popover';
|
|
20
|
+
import Button from '../../button';
|
|
21
|
+
import Dialog from '../../utilities/dialog';
|
|
22
|
+
import IconSettings from '../../icon-settings';
|
|
23
|
+
|
|
24
|
+
/* Set Chai to use chaiEnzyme for enzyme compatible assertions:
|
|
25
|
+
* https://github.com/producthunt/chai-enzyme
|
|
26
|
+
*/
|
|
27
|
+
chai.use(chaiEnzyme());
|
|
28
|
+
|
|
29
|
+
const defaultProps = {
|
|
30
|
+
id: 'sample-popover',
|
|
31
|
+
body: <span id="sample-body">This is the body</span>,
|
|
32
|
+
heading: <span id="sample-heading">This is the heading</span>,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const defaultIds = {
|
|
36
|
+
trigger: `button#${defaultProps.id}`,
|
|
37
|
+
popover: `${defaultProps.id}-popover`,
|
|
38
|
+
body: `${defaultProps.id}-dialog-body`,
|
|
39
|
+
heading: `${defaultProps.id}-dialog-heading`,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/* A re-usable demo component fixture outside of `describe` sections
|
|
43
|
+
* can accept props within each test and be unmounted after each tests.
|
|
44
|
+
* This wrapping component will be similar to your wrapping component
|
|
45
|
+
* you will create in the React Storybook for manual testing.
|
|
46
|
+
*/
|
|
47
|
+
class DemoComponent extends React.Component {
|
|
48
|
+
static displayName = 'PopoverDemoComponent';
|
|
49
|
+
|
|
50
|
+
static propTypes = {
|
|
51
|
+
isOpen: PropTypes.bool,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
static defaultProps = defaultProps;
|
|
55
|
+
|
|
56
|
+
state = {};
|
|
57
|
+
|
|
58
|
+
// event handlers
|
|
59
|
+
|
|
60
|
+
render() {
|
|
61
|
+
return (
|
|
62
|
+
<IconSettings iconPath="/assets/icons">
|
|
63
|
+
<div>
|
|
64
|
+
<Popover {...this.props}>
|
|
65
|
+
<Button label="Trigger Popover" />
|
|
66
|
+
</Popover>
|
|
67
|
+
<Button id="not-the-trigger" label="Not Trigger Popover" />
|
|
68
|
+
</div>
|
|
69
|
+
</IconSettings>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* All tests for component being tested should be wrapped in a root `describe`,
|
|
75
|
+
* which should be named after the component being tested.
|
|
76
|
+
* When read aloud, the cumulative `describe` and `it` names should form a coherent
|
|
77
|
+
* sentence, eg "Date Picker default structure and css is present with expected
|
|
78
|
+
* attributes set". If you are having trouble constructing a cumulative short
|
|
79
|
+
* sentence, this may be an indicator that your test is poorly structured.
|
|
80
|
+
* String provided as first parameter names the `describe` section. Limit to nouns
|
|
81
|
+
* as much as possible/appropriate.`
|
|
82
|
+
*/
|
|
83
|
+
describe('SLDSPopover', function () {
|
|
84
|
+
let mountNode;
|
|
85
|
+
let wrapper;
|
|
86
|
+
|
|
87
|
+
// BASIC STRUCTURE
|
|
88
|
+
|
|
89
|
+
describe('Default structure and css', function () {
|
|
90
|
+
beforeEach(() => {
|
|
91
|
+
mountNode = createMountNode({ context: this });
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
afterEach(() => {
|
|
95
|
+
destroyMountNode({ wrapper, mountNode });
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('is open, has heading, body, close button', () => {
|
|
99
|
+
wrapper = mount(<DemoComponent isOpen />, { attachTo: mountNode });
|
|
100
|
+
|
|
101
|
+
expect(wrapper.find(`#${defaultIds.heading}`)).to.exist;
|
|
102
|
+
expect(wrapper.find(`#${defaultIds.body}`)).to.exist;
|
|
103
|
+
expect(wrapper.find('.slds-popover__close')).to.exist;
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe('Assistive technology', () => {
|
|
108
|
+
/* Detect if presence of accessibility features such as ARIA
|
|
109
|
+
* roles and screen reader text is present in the DOM.
|
|
110
|
+
*/
|
|
111
|
+
beforeEach(() => {
|
|
112
|
+
mountNode = createMountNode({ context: this });
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
afterEach(() => {
|
|
116
|
+
destroyMountNode({ wrapper, mountNode });
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('has aria-labelledby/aria-describedby on popover', function () {
|
|
120
|
+
wrapper = mount(<DemoComponent isOpen />, { attachTo: mountNode });
|
|
121
|
+
|
|
122
|
+
const popover = wrapper.find(`#${defaultIds.popover}`);
|
|
123
|
+
expect(popover).to.have.attr('aria-labelledby', defaultIds.heading);
|
|
124
|
+
expect(popover).to.have.attr('aria-describedby', defaultIds.body);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// PROPS AND CHILDREN
|
|
129
|
+
|
|
130
|
+
describe('Optional props', () => {
|
|
131
|
+
const popoverBackgroundColor = 'rgb(255, 80, 121)';
|
|
132
|
+
const containerBackgroundColor = 'rgb(255, 127, 80)';
|
|
133
|
+
// What should be present in the DOM when style and className are applied?
|
|
134
|
+
const optionalProps = {
|
|
135
|
+
className: 'sample-classname',
|
|
136
|
+
assistiveText: {
|
|
137
|
+
closeButton: 'Shut it now!',
|
|
138
|
+
},
|
|
139
|
+
containerClassName: 'sample-container-classname',
|
|
140
|
+
containerStyle: { background: containerBackgroundColor },
|
|
141
|
+
footer: <p id="footer">Footer</p>,
|
|
142
|
+
style: { background: popoverBackgroundColor },
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
beforeEach(() => {
|
|
146
|
+
mountNode = createMountNode({ context: this });
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
afterEach(() => {
|
|
150
|
+
destroyMountNode({ wrapper, mountNode });
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('has correct className, assistiveText, style, and footer', function () {
|
|
154
|
+
wrapper = mount(<DemoComponent {...optionalProps} isOpen />, {
|
|
155
|
+
attachTo: mountNode,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const popover = wrapper.find(Dialog);
|
|
159
|
+
|
|
160
|
+
expect(popover).to.have.className(optionalProps.className);
|
|
161
|
+
expect(popover.find('button.slds-popover__close')).to.have.text(
|
|
162
|
+
optionalProps.assistiveText.closeButton
|
|
163
|
+
);
|
|
164
|
+
expect(popover.find('#footer')).to.exist;
|
|
165
|
+
expect(popover.prop('style').background).to.equal(popoverBackgroundColor);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// EVENTS
|
|
170
|
+
|
|
171
|
+
describe('Mouse and keyboard interactions', () => {
|
|
172
|
+
/* Test event callback functions using Simulate. For more information, view
|
|
173
|
+
* https://github.com/airbnb/enzyme/blob/master/docs/api/ReactWrapper/simulate.md
|
|
174
|
+
*/
|
|
175
|
+
describe('onClick', function () {
|
|
176
|
+
const triggerClicked = sinon.spy();
|
|
177
|
+
|
|
178
|
+
beforeEach(() => {
|
|
179
|
+
mountNode = createMountNode({ context: this });
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
afterEach(() => {
|
|
183
|
+
destroyMountNode({ wrapper, mountNode });
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('calls onClick handler on trigger, click on popover close closes', function (done) {
|
|
187
|
+
wrapper = mount(
|
|
188
|
+
<DemoComponent
|
|
189
|
+
onClick={triggerClicked}
|
|
190
|
+
onClose={() => {
|
|
191
|
+
setTimeout(() => {
|
|
192
|
+
const popover = wrapper.find(`#${defaultIds.popover}`);
|
|
193
|
+
expect(popover).to.not.exist;
|
|
194
|
+
done();
|
|
195
|
+
}, 0);
|
|
196
|
+
}}
|
|
197
|
+
onOpen={() => {
|
|
198
|
+
wrapper.update();
|
|
199
|
+
const popover = wrapper.find(`#${defaultIds.popover}`);
|
|
200
|
+
|
|
201
|
+
expect(popover).to.exist;
|
|
202
|
+
expect(triggerClicked.callCount).to.equal(1);
|
|
203
|
+
|
|
204
|
+
popover.find('button.slds-popover__close').simulate('click');
|
|
205
|
+
}}
|
|
206
|
+
position="absolute"
|
|
207
|
+
/>,
|
|
208
|
+
{ attachTo: mountNode }
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
const trigger = wrapper.find(defaultIds.trigger);
|
|
212
|
+
trigger.simulate('click');
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('opens on click, closes on ESC', function (done) {
|
|
216
|
+
wrapper = mount(
|
|
217
|
+
<DemoComponent
|
|
218
|
+
onClose={() => {
|
|
219
|
+
setTimeout(() => {
|
|
220
|
+
const popover = wrapper.find(`#${defaultIds.popover}`);
|
|
221
|
+
expect(popover).to.not.exist;
|
|
222
|
+
done();
|
|
223
|
+
}, 0);
|
|
224
|
+
}}
|
|
225
|
+
onOpen={() => {
|
|
226
|
+
wrapper.update();
|
|
227
|
+
const popover = wrapper.find(`#${defaultIds.popover}`);
|
|
228
|
+
popover.simulate('keyDown', {
|
|
229
|
+
key: 'Esc',
|
|
230
|
+
keyCode: 27,
|
|
231
|
+
which: 27,
|
|
232
|
+
});
|
|
233
|
+
}}
|
|
234
|
+
/>,
|
|
235
|
+
{ attachTo: mountNode }
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
const trigger = wrapper.find(defaultIds.trigger);
|
|
239
|
+
trigger.simulate('click');
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('stops event propagation after closing on ESC', function (done) {
|
|
243
|
+
const mockEvent = {
|
|
244
|
+
key: 'Esc',
|
|
245
|
+
keyCode: 27,
|
|
246
|
+
which: 27,
|
|
247
|
+
stopPropagation: sinon.spy(),
|
|
248
|
+
};
|
|
249
|
+
wrapper = mount(
|
|
250
|
+
<DemoComponent
|
|
251
|
+
onOpen={() => {
|
|
252
|
+
wrapper.update();
|
|
253
|
+
const popover = wrapper.find(`#${defaultIds.popover}`);
|
|
254
|
+
popover.simulate('keyDown', mockEvent);
|
|
255
|
+
}}
|
|
256
|
+
onKeyDown={() => {
|
|
257
|
+
setTimeout(() => {
|
|
258
|
+
expect(mockEvent.stopPropagation.callCount).to.equal(1);
|
|
259
|
+
done();
|
|
260
|
+
}, 0);
|
|
261
|
+
}}
|
|
262
|
+
/>,
|
|
263
|
+
{ attachTo: mountNode }
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
const trigger = wrapper.find(defaultIds.trigger);
|
|
267
|
+
trigger.simulate('click');
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
describe('focus has moved to dialog', function () {
|
|
273
|
+
const triggerClicked = sinon.spy();
|
|
274
|
+
|
|
275
|
+
beforeEach(() => {
|
|
276
|
+
mountNode = createMountNode({ context: this });
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
afterEach(() => {
|
|
280
|
+
destroyMountNode({ wrapper, mountNode });
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('focus moves to correct node on open', function (done) {
|
|
284
|
+
wrapper = mount(
|
|
285
|
+
<DemoComponent
|
|
286
|
+
onClick={triggerClicked}
|
|
287
|
+
onOpen={() => {
|
|
288
|
+
expect(document.activeElement.id).to.equal(`${defaultIds.popover}`);
|
|
289
|
+
done();
|
|
290
|
+
}}
|
|
291
|
+
/>,
|
|
292
|
+
{ attachTo: mountNode }
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
const trigger = wrapper.find(defaultIds.trigger);
|
|
296
|
+
trigger.simulate('click', {});
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
describe('Disabled', function () {
|
|
301
|
+
const triggerClicked = sinon.spy();
|
|
302
|
+
const popoverOpened = sinon.spy();
|
|
303
|
+
|
|
304
|
+
beforeEach(() => {
|
|
305
|
+
mountNode = createMountNode({ context: this });
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
afterEach(() => {
|
|
309
|
+
destroyMountNode({ wrapper, mountNode });
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('onOpen is not called when disabled', function () {
|
|
313
|
+
wrapper = mount(
|
|
314
|
+
<DemoComponent
|
|
315
|
+
disabled
|
|
316
|
+
onClick={triggerClicked}
|
|
317
|
+
onOpen={popoverOpened}
|
|
318
|
+
/>,
|
|
319
|
+
{ attachTo: mountNode }
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
const trigger = wrapper.find(defaultIds.trigger);
|
|
323
|
+
trigger.simulate('click', {});
|
|
324
|
+
expect(popoverOpened.callCount).to.equal(0);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
});
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/* Adds all of the Mocha (eg `it` and `should`) and sinon testing global
|
|
2
|
+
* variables to the global namespace for eslint purposes.
|
|
3
|
+
*/
|
|
4
|
+
/* eslint-env mocha */
|
|
5
|
+
/* global sinon */
|
|
6
|
+
|
|
7
|
+
// Additional modifiers to [eslint-config-slds](https://github.com/salesforce-ux/eslint-config-slds) for convenience
|
|
8
|
+
/* eslint-disable no-console */
|
|
9
|
+
/* eslint-disable no-unused-expressions */
|
|
10
|
+
/* eslint-disable max-len */
|
|
11
|
+
/* eslint-disable prefer-arrow-callback */
|
|
12
|
+
/* eslint-disable react/display-name */
|
|
13
|
+
|
|
14
|
+
// Import your external dependencies
|
|
15
|
+
import React from 'react';
|
|
16
|
+
|
|
17
|
+
import { expect } from 'chai';
|
|
18
|
+
|
|
19
|
+
import SLDSProgressIndicator from '../../progress-indicator';
|
|
20
|
+
import IconSettings from '../../icon-settings';
|
|
21
|
+
|
|
22
|
+
/* Enzyme Helpers that can mount and unmount React component instances to
|
|
23
|
+
* the DOM and set `this.wrapper` and `this.dom` within Mocha's `this`
|
|
24
|
+
* context [full source here](tests/enzyme-helpers.js). `this` can
|
|
25
|
+
* only be referenced if inside `function () {}`.
|
|
26
|
+
*/
|
|
27
|
+
import {
|
|
28
|
+
mountComponent,
|
|
29
|
+
unmountComponent,
|
|
30
|
+
} from '../../../tests/enzyme-helpers';
|
|
31
|
+
|
|
32
|
+
const defaultProps = {
|
|
33
|
+
id: 'sample-progress-indicator',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const mockCallback = sinon.spy();
|
|
37
|
+
|
|
38
|
+
class DemoComponent extends React.Component {
|
|
39
|
+
static displayName = 'ProgressIndicatorDemoComponent';
|
|
40
|
+
|
|
41
|
+
static propTypes = {
|
|
42
|
+
onStepClick: mockCallback,
|
|
43
|
+
onStepFocus: mockCallback,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
static defaultProps = defaultProps;
|
|
47
|
+
|
|
48
|
+
render() {
|
|
49
|
+
return (
|
|
50
|
+
<IconSettings iconPath="/assets/icons">
|
|
51
|
+
<SLDSProgressIndicator {...this.props} />
|
|
52
|
+
</IconSettings>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const steps = [
|
|
58
|
+
{ id: 0, label: 'tooltip label #1' },
|
|
59
|
+
{ id: 1, label: 'tooltip label #2' },
|
|
60
|
+
{ id: 2, label: 'tooltip label #3' },
|
|
61
|
+
{ id: 3, label: 'tooltip label #4' },
|
|
62
|
+
{ id: 4, label: 'tooltip label #5' },
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
const sixSteps = [
|
|
66
|
+
{ id: 0, label: 'custom tooltip #1' },
|
|
67
|
+
{ id: 1, label: 'tooltip label #2' },
|
|
68
|
+
{ id: 2, label: 'tooltip label #3' },
|
|
69
|
+
{ id: 3, label: 'tooltip label #4' },
|
|
70
|
+
{ id: 4, label: 'tooltip label #5' },
|
|
71
|
+
{ id: 5, label: 'tooltip label #6' },
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
describe('SLDSProgressIndicator: ', () => {
|
|
75
|
+
describe('Basic Props Render', () => {
|
|
76
|
+
beforeEach(
|
|
77
|
+
mountComponent(
|
|
78
|
+
<DemoComponent
|
|
79
|
+
steps={steps}
|
|
80
|
+
selectedStep={steps[2]}
|
|
81
|
+
completedSteps={steps.slice(0, 2)}
|
|
82
|
+
/>
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
afterEach(unmountComponent);
|
|
87
|
+
|
|
88
|
+
// PROPS
|
|
89
|
+
it('has five steps by default', function () {
|
|
90
|
+
const item = this.wrapper.find('.slds-progress').find('li');
|
|
91
|
+
expect(item).to.have.length(5);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('has only one active step', function () {
|
|
95
|
+
const item = this.wrapper
|
|
96
|
+
.find('.slds-progress')
|
|
97
|
+
.find('li.slds-is-active');
|
|
98
|
+
expect(item).to.have.length(1);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('does not have an error step', function () {
|
|
102
|
+
const item = this.wrapper
|
|
103
|
+
.find('.slds-progress')
|
|
104
|
+
.find('li.slds-has-error');
|
|
105
|
+
expect(item).to.have.length(0);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('has correct number of completed steps', function () {
|
|
109
|
+
const item = this.wrapper
|
|
110
|
+
.find('.slds-progress')
|
|
111
|
+
.find('li.slds-is-completed');
|
|
112
|
+
expect(item).to.have.length(2);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('has a white background', function () {
|
|
116
|
+
const item = this.wrapper.find('.slds-progress_shade');
|
|
117
|
+
expect(item).to.have.length(0);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
describe('Within-Modal Props Render (Without Error)', () => {
|
|
122
|
+
beforeEach(
|
|
123
|
+
mountComponent(
|
|
124
|
+
<DemoComponent
|
|
125
|
+
steps={steps}
|
|
126
|
+
selectedStep={steps[2]}
|
|
127
|
+
completedSteps={steps.slice(0, 2)}
|
|
128
|
+
variant="modal"
|
|
129
|
+
/>
|
|
130
|
+
)
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
afterEach(unmountComponent);
|
|
134
|
+
|
|
135
|
+
// PROPS
|
|
136
|
+
it('has 5 steps by default', function () {
|
|
137
|
+
const item = this.wrapper.find('.slds-progress').find('li');
|
|
138
|
+
expect(item).to.have.length(5);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('has no error step', function () {
|
|
142
|
+
const item = this.wrapper
|
|
143
|
+
.find('.slds-progress')
|
|
144
|
+
.find('li.slds-has-error');
|
|
145
|
+
expect(item).to.have.length(0);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('has 1 active step', function () {
|
|
149
|
+
const item = this.wrapper
|
|
150
|
+
.find('.slds-progress')
|
|
151
|
+
.find('li.slds-is-active');
|
|
152
|
+
expect(item).to.have.length(1);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('has correct number of completed steps', function () {
|
|
156
|
+
const item = this.wrapper
|
|
157
|
+
.find('.slds-progress')
|
|
158
|
+
.find('li.slds-is-completed');
|
|
159
|
+
expect(item).to.have.length(2);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('has a gray background', function () {
|
|
163
|
+
const item = this.wrapper.find('.slds-progress_shade');
|
|
164
|
+
expect(item).to.have.length(1);
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
describe('Within-Modal Props Render (With Error)', () => {
|
|
169
|
+
beforeEach(
|
|
170
|
+
mountComponent(
|
|
171
|
+
<DemoComponent
|
|
172
|
+
steps={steps}
|
|
173
|
+
selectedStep={steps[2]}
|
|
174
|
+
errorSteps={steps.slice(2, 3)}
|
|
175
|
+
completedSteps={steps.slice(0, 2)}
|
|
176
|
+
variant="modal"
|
|
177
|
+
/>
|
|
178
|
+
)
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
afterEach(unmountComponent);
|
|
182
|
+
|
|
183
|
+
// PROPS
|
|
184
|
+
it('has 1 error step', function () {
|
|
185
|
+
const item = this.wrapper
|
|
186
|
+
.find('.slds-progress')
|
|
187
|
+
.find('li.slds-has-error');
|
|
188
|
+
expect(item).to.have.length(1);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('has no active step', function () {
|
|
192
|
+
const item = this.wrapper
|
|
193
|
+
.find('.slds-progress')
|
|
194
|
+
.find('li.slds-is-active');
|
|
195
|
+
expect(item).to.have.length(0);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('has correct number of completed steps', function () {
|
|
199
|
+
const item = this.wrapper
|
|
200
|
+
.find('.slds-progress')
|
|
201
|
+
.find('li.slds-is-completed');
|
|
202
|
+
expect(item).to.have.length(2);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
describe('Tooltip Props Render', () => {
|
|
207
|
+
beforeEach(
|
|
208
|
+
mountComponent(
|
|
209
|
+
<DemoComponent
|
|
210
|
+
steps={sixSteps}
|
|
211
|
+
selectedStep={sixSteps[2]}
|
|
212
|
+
errorSteps={sixSteps.slice(2, 3)}
|
|
213
|
+
completedSteps={sixSteps.slice(0, 2)}
|
|
214
|
+
/>
|
|
215
|
+
)
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
afterEach(unmountComponent);
|
|
219
|
+
|
|
220
|
+
// PROPS
|
|
221
|
+
it('has an error step', function () {
|
|
222
|
+
const item = this.wrapper
|
|
223
|
+
.find('.slds-progress')
|
|
224
|
+
.find('li.slds-has-error');
|
|
225
|
+
expect(item).to.have.length(1);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('has a tooltip attached to every step', function () {
|
|
229
|
+
const item = this.wrapper
|
|
230
|
+
.find('.slds-progress')
|
|
231
|
+
.find('.slds-tooltip-trigger');
|
|
232
|
+
expect(item).to.have.length(6);
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
describe('Click Event', () => {
|
|
237
|
+
const clickHandler = sinon.spy();
|
|
238
|
+
|
|
239
|
+
beforeEach(
|
|
240
|
+
mountComponent(
|
|
241
|
+
<DemoComponent
|
|
242
|
+
steps={steps}
|
|
243
|
+
selectedStep={steps[2]}
|
|
244
|
+
completedSteps={steps.slice(0, 2)}
|
|
245
|
+
onStepClick={clickHandler}
|
|
246
|
+
/>
|
|
247
|
+
)
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
afterEach(unmountComponent);
|
|
251
|
+
|
|
252
|
+
// EVENTS
|
|
253
|
+
it('calls onStepClick()', function () {
|
|
254
|
+
const step = this.wrapper
|
|
255
|
+
.find('.slds-progress')
|
|
256
|
+
.find('li')
|
|
257
|
+
.find('button')
|
|
258
|
+
.first();
|
|
259
|
+
step.simulate('click'); // <-- this is causing some errors on tab tests
|
|
260
|
+
expect(clickHandler.callCount).to.equal(1);
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
describe('Click Event for Vertical Orientation', () => {
|
|
265
|
+
const clickHandler = sinon.spy();
|
|
266
|
+
|
|
267
|
+
beforeEach(
|
|
268
|
+
mountComponent(
|
|
269
|
+
<DemoComponent
|
|
270
|
+
steps={steps}
|
|
271
|
+
selectedStep={steps[2]}
|
|
272
|
+
completedSteps={steps.slice(0, 2)}
|
|
273
|
+
onStepClick={clickHandler}
|
|
274
|
+
orientation="vertical"
|
|
275
|
+
/>
|
|
276
|
+
)
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
afterEach(unmountComponent);
|
|
280
|
+
|
|
281
|
+
// EVENTS
|
|
282
|
+
it('calls onStepClick()', function () {
|
|
283
|
+
const step = this.wrapper
|
|
284
|
+
.find('.slds-progress')
|
|
285
|
+
.find('li')
|
|
286
|
+
.find('span')
|
|
287
|
+
.first();
|
|
288
|
+
step.simulate('click'); // <-- this is causing some errors on tab tests
|
|
289
|
+
expect(clickHandler.callCount).to.equal(1);
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
describe('Assistive Technology', () => {
|
|
294
|
+
/* Detect if presence of accessibility features such as ARIA
|
|
295
|
+
* roles and screen reader text is present in the DOM.
|
|
296
|
+
*/
|
|
297
|
+
const focusHandler = sinon.spy();
|
|
298
|
+
|
|
299
|
+
beforeEach(
|
|
300
|
+
mountComponent(
|
|
301
|
+
<DemoComponent
|
|
302
|
+
steps={steps}
|
|
303
|
+
selectedStep={steps[2]}
|
|
304
|
+
completedSteps={steps.slice(0, 2)}
|
|
305
|
+
onStepFocus={focusHandler}
|
|
306
|
+
/>
|
|
307
|
+
)
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
afterEach(unmountComponent);
|
|
311
|
+
|
|
312
|
+
// A11Y FEATURES
|
|
313
|
+
it('specifies the role for progress bar', function () {
|
|
314
|
+
const progressbarRole = this.wrapper.find('div[role="progressbar"]');
|
|
315
|
+
expect(progressbarRole).to.have.length(1);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it('renders assistive text for progress bar', function () {
|
|
319
|
+
const item = this.wrapper
|
|
320
|
+
.find('.slds-progress-bar')
|
|
321
|
+
.find('.slds-assistive-text')
|
|
322
|
+
.first();
|
|
323
|
+
expect(item.text()).to.include('Progress:');
|
|
324
|
+
expect(item.text()).to.include('%');
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* TODO in the future:
|
|
330
|
+
* we may want to extend test cases when TetherJS is removed for future dev
|
|
331
|
+
* The following cases may be considered:
|
|
332
|
+
* 1. test tooltips behave properly (show/hide/with correct label) *on hover*
|
|
333
|
+
* 2. test tooltips behave properly *on focus/blur*
|
|
334
|
+
*/
|
|
335
|
+
});
|