@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.
Files changed (69) hide show
  1. package/components/accordion/__tests__/accordion.browser-test.jsx +302 -0
  2. package/components/alert/__tests__/alert.browser-test.jsx +100 -0
  3. package/components/app-launcher/__tests__/app-launcher.browser-test.jsx +228 -0
  4. package/components/app-launcher/__tests__/expandable-section.browser-test.jsx +144 -0
  5. package/components/app-launcher/__tests__/link.browser-test.jsx +107 -0
  6. package/components/app-launcher/__tests__/tile.browser-test.jsx +267 -0
  7. package/components/avatar/__tests__/avatar.browser-test.jsx +207 -0
  8. package/components/builder-header/__tests__/builder-header.browser-test.jsx +53 -0
  9. package/components/button/__tests__/button.browser-test.jsx +226 -0
  10. package/components/button-group/__tests__/button-group.browser-test.jsx +144 -0
  11. package/components/button-stateful/__tests__/button-stateful.browser-test.jsx +125 -0
  12. package/components/card/__tests__/card.browser-test.jsx +255 -0
  13. package/components/carousel/__tests__/carousel.browser-test.jsx +527 -0
  14. package/components/color-picker/__tests__/color-picker.browser-test.jsx +767 -0
  15. package/components/combobox/__tests__/combobox.browser-test.jsx +654 -0
  16. package/components/data-table/__tests__/data-table.browser-test.jsx +1051 -0
  17. package/components/date-picker/__tests__/__snapshots__/datepicker.dom-snapshot-test.jsx.snap +4429 -0
  18. package/components/date-picker/__tests__/date-picker.browser-test.jsx +497 -0
  19. package/components/date-picker/__tests__/datepicker.dom-snapshot-test.jsx +109 -0
  20. package/components/docked-composer/__tests__/docked-composer.browser-test.jsx +83 -0
  21. package/components/expandable-section/__tests__/expandable-section.browser-test.jsx +133 -0
  22. package/components/expression/__tests__/expression.browser-test.jsx +255 -0
  23. package/components/filter/__tests__/filter.browser-test.jsx +147 -0
  24. package/components/forms/input/__tests__/inline.browser-test.jsx +164 -0
  25. package/components/global-header/__tests__/global-header.browser-test.jsx +177 -0
  26. package/components/global-navigation-bar/__tests__/global-navigation-bar.browser-test.jsx +464 -0
  27. package/components/icon/__tests__/icon.browser-test.jsx +214 -0
  28. package/components/illustration/__tests__/illustration.browser-test.jsx +177 -0
  29. package/components/input/__tests__/input.browser-test.jsx +612 -0
  30. package/components/location-map/__tests__/location-map.browser-test.jsx +158 -0
  31. package/components/lookup/__tests__/lookup.browser-test.jsx +353 -0
  32. package/components/media-object/__tests__/media-object.browser-test.jsx +87 -0
  33. package/components/menu-dropdown/__tests__/dropdown.browser-test.jsx +588 -0
  34. package/components/menu-picklist/__tests__/menupicklist.snapshot-old-test.jsx +41 -0
  35. package/components/menu-picklist/__tests__/picklist-base.browser-test.jsx +275 -0
  36. package/components/modal/__tests__/modal.browser-test.jsx +333 -0
  37. package/components/notification/__tests__/notification.browser-test.jsx +113 -0
  38. package/components/page-header/__tests__/page-header.browser-test.jsx +161 -0
  39. package/components/panel/__tests__/__snapshots__/filtering.dom-snapshot-test.jsx.snap +298 -0
  40. package/components/panel/__tests__/filtering.dom-snapshot-test.jsx +9 -0
  41. package/components/pill/__tests__/pill.browser-test.jsx +308 -0
  42. package/components/pill-container/__tests__/pill-container.browser-test.jsx +186 -0
  43. package/components/popover/__tests__/popover.browser-test.jsx +327 -0
  44. package/components/progress-indicator/__tests__/progress-indicator.browser-test.jsx +335 -0
  45. package/components/radio-button-group/__tests__/radio-button-group.browser-test.jsx +122 -0
  46. package/components/radio-group/__tests__/radio-group.browser-test.jsx +119 -0
  47. package/components/setup-assistant/__tests__/setup-assistant.browser-test.jsx +77 -0
  48. package/components/slider/__tests__/slider.browser-test.jsx +389 -0
  49. package/components/spinner/__tests__/spinner.browser-test.jsx +57 -0
  50. package/components/split-view/__tests__/split-view.listbox.browser-test.jsx +225 -0
  51. package/components/split-view/__tests__/split-view.listbox.header.browser-test.jsx +158 -0
  52. package/components/split-view/__tests__/split-view.listbox.unread.browser-test.jsx +114 -0
  53. package/components/tabs/__tests__/tabs.browser-test.jsx +458 -0
  54. package/components/textarea/__tests__/textarea.browser-test.jsx +175 -0
  55. package/components/time-picker/__tests__/time-picker.browser-test.jsx +46 -0
  56. package/components/toast/__tests__/toast.browser-test.jsx +118 -0
  57. package/components/tooltip/__tests__/tooltip.browser-test.jsx +214 -0
  58. package/components/tree/__tests__/tree.browser-test.jsx +303 -0
  59. package/components/vertical-navigation/__tests__/navigation.browser-test.jsx +117 -0
  60. package/components/visual-picker/__tests__/visual-picker.browser-test.jsx +288 -0
  61. package/components/welcome-mat/__tests__/welcome-mat.browser-test.jsx +358 -0
  62. package/design-system-react-components.js +1 -1
  63. package/design-system-react-components.min.js.LICENSE.txt +1 -1
  64. package/design-system-react.js +1 -1
  65. package/design-system-react.min.js.LICENSE.txt +1 -1
  66. package/lib/design-system-react-components.min.js.LICENSE.txt +1 -1
  67. package/lib/design-system-react.min.js.LICENSE.txt +1 -1
  68. package/lib/package.json +1 -1
  69. package/package.json +1 -1
@@ -0,0 +1,117 @@
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
+ // Import your external dependencies
8
+ import React from 'react';
9
+
10
+ import PropTypes from 'prop-types';
11
+ import chai, { expect } from 'chai';
12
+ import chaiEnzyme from 'chai-enzyme';
13
+
14
+ /* Enzyme Helpers that can mount and unmount React component instances to
15
+ * the DOM and set `this.wrapper` and `this.dom` within Mocha's `this`
16
+ * context [full source here](tests/enzyme-helpers.js). `this` can
17
+ * only be referenced if inside `function () {}`.
18
+ */
19
+ import {
20
+ mountComponent,
21
+ unmountComponent,
22
+ } from '../../../tests/enzyme-helpers';
23
+
24
+ import { sampleReportCategories } from '../../../utilities/sample-data/vertical-navigation';
25
+ import VerticalNavigation from '../../vertical-navigation';
26
+
27
+ /* Set Chai to use chaiEnzyme for enzyme compatible assertions:
28
+ * https://github.com/producthunt/chai-enzyme
29
+ */
30
+ chai.use(chaiEnzyme());
31
+
32
+ const defaultProps = {
33
+ id: 'sample-navigation',
34
+ className: 'sample-navigation',
35
+ categories: sampleReportCategories,
36
+ };
37
+
38
+ /* A re-usable demo component fixture outside of `describe` sections
39
+ * can accept props within each test and be unmounted after each tests.
40
+ */
41
+ class DemoComponent extends React.Component {
42
+ static displayName = 'NavigationDemoComponent';
43
+
44
+ static propTypes = {
45
+ selectedId: PropTypes.string,
46
+ onSelect: PropTypes.func,
47
+ };
48
+
49
+ static defaultProps = defaultProps;
50
+
51
+ state = {};
52
+
53
+ // event handlers
54
+
55
+ render() {
56
+ return <VerticalNavigation {...this.props} />;
57
+ }
58
+ }
59
+
60
+ describe('SLDSVerticalNavigation', () => {
61
+ describe('Assistive technology', () => {
62
+ /* Detect if presence of accessibility features such as ARIA
63
+ * roles and screen reader text is present in the DOM.
64
+ */
65
+ beforeEach(mountComponent(<DemoComponent />));
66
+
67
+ afterEach(unmountComponent);
68
+
69
+ it('has items described by category headers', function () {
70
+ const structure = { reports: 5, folders: 3 };
71
+ Object.entries(structure).forEach(([categoryId, itemCount]) => {
72
+ const header = this.wrapper.find(`#sample-navigation-${categoryId}`);
73
+ expect(header).to.have.length(1);
74
+ const ariaDescribedbyId = this.wrapper.find(
75
+ `a[aria-describedby="sample-navigation-${categoryId}"]`
76
+ );
77
+ expect(ariaDescribedbyId).to.have.length(itemCount);
78
+ });
79
+ });
80
+ });
81
+
82
+ // PROPS
83
+
84
+ describe('selectedId prop', () => {
85
+ const selectedId = 'my_folders';
86
+
87
+ beforeEach(mountComponent(<DemoComponent selectedId={selectedId} />));
88
+
89
+ afterEach(unmountComponent);
90
+
91
+ it('is used to select an item', function () {
92
+ const item = this.wrapper
93
+ .find('.sample-navigation')
94
+ .find('li.slds-is-active')
95
+ .find('a[data-id="my_folders"]');
96
+ expect(item).to.have.length(1);
97
+ });
98
+ });
99
+
100
+ // EVENTS
101
+
102
+ describe('Item', () => {
103
+ const clickHandler = sinon.spy();
104
+
105
+ beforeEach(mountComponent(<DemoComponent onSelect={clickHandler} />));
106
+
107
+ afterEach(unmountComponent);
108
+
109
+ it('calls onSelect', function () {
110
+ const item = this.wrapper
111
+ .find('.sample-navigation')
112
+ .find('a[data-id="my_folders"]');
113
+ item.simulate('click');
114
+ expect(clickHandler.callCount).to.equal(1);
115
+ });
116
+ });
117
+ });
@@ -0,0 +1,288 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import chai, { expect } from 'chai';
4
+ import chaiEnzyme from 'chai-enzyme';
5
+ import { mount } from 'enzyme';
6
+
7
+ /* Enzyme Helpers that can mount and unmount React component instances to
8
+ * the DOM and set `this.wrapper` and `this.dom` within Mocha's `this`
9
+ * context [full source here](tests/enzyme-helpers.js). `this` can
10
+ * only be referenced if inside `function () {}`.
11
+ */
12
+ import {
13
+ createMountNode,
14
+ destroyMountNode,
15
+ } from '../../../tests/enzyme-helpers';
16
+
17
+ import IconSettings from '../../icon-settings';
18
+ import Icon from '../../icon';
19
+ import VisualPicker from '../../visual-picker';
20
+ import Radio from '../../radio';
21
+ import Checkbox from '../../checkbox';
22
+
23
+ chai.use(chaiEnzyme());
24
+
25
+ /* Re-usable demo component.
26
+ */
27
+ class VisualPickerExample extends React.Component {
28
+ constructor(props) {
29
+ super(props);
30
+ this.state = { checked: this.props.checked };
31
+ }
32
+
33
+ render() {
34
+ return (
35
+ <IconSettings iconPath="/assets/icons">
36
+ <VisualPicker
37
+ label={this.props.label}
38
+ id={this.props.id}
39
+ size="medium"
40
+ coverable
41
+ >
42
+ {this.props.type === 'radio' ? (
43
+ <React.Fragment>
44
+ <Radio
45
+ labels={{
46
+ label: 'Connected App',
47
+ }}
48
+ id={`${this.props.id}-1`}
49
+ value="1"
50
+ checked={this.state.checked === '1'}
51
+ onChange={() => this.setState({ checked: '1' })}
52
+ onRenderVisualPickerSelected={() => (
53
+ <Icon
54
+ assistiveText={{ label: 'selected-icon' }}
55
+ category="utility"
56
+ name="check"
57
+ colorVariant="base"
58
+ size="large"
59
+ />
60
+ )}
61
+ onRenderVisualPickerNotSelected={() => (
62
+ <Icon
63
+ assistiveText={{ label: 'connected_apps-icon' }}
64
+ category="utility"
65
+ name="connected_apps"
66
+ size="large"
67
+ />
68
+ )}
69
+ />
70
+ <Radio
71
+ labels={{
72
+ label: 'Custom App',
73
+ }}
74
+ id={`${this.props.id}-2`}
75
+ value="2"
76
+ checked={this.state.checked === '2'}
77
+ onChange={() => this.setState({ checked: '2' })}
78
+ onRenderVisualPickerSelected={() => (
79
+ <Icon
80
+ assistiveText={{ label: 'selected-icon' }}
81
+ category="utility"
82
+ name="check"
83
+ colorVariant="base"
84
+ size="large"
85
+ />
86
+ )}
87
+ onRenderVisualPickerNotSelected={() => (
88
+ <Icon
89
+ assistiveText={{ label: 'custom_apps-icon' }}
90
+ category="utility"
91
+ name="custom_apps"
92
+ size="large"
93
+ />
94
+ )}
95
+ />
96
+ </React.Fragment>
97
+ ) : (
98
+ <React.Fragment>
99
+ <Checkbox
100
+ labels={{
101
+ label: 'Account',
102
+ }}
103
+ value="1"
104
+ checked={this.state.checked.includes('1')}
105
+ onChange={() => {
106
+ if (this.state.checked.includes('1'))
107
+ this.setState({
108
+ checked: this.state.checked.filter(
109
+ (item) => item !== '1'
110
+ ),
111
+ });
112
+ else this.setState({ checked: [...this.state.checked, '1'] });
113
+ }}
114
+ id="visual-picker-coverable-checkbox-1"
115
+ onRenderVisualPickerSelected={() => (
116
+ <Icon
117
+ assistiveText={this.props.assistiveText}
118
+ category="utility"
119
+ name="check"
120
+ colorVariant="base"
121
+ size="large"
122
+ />
123
+ )}
124
+ onRenderVisualPickerNotSelected={() => (
125
+ <Icon
126
+ assistiveText={this.props.assistiveText}
127
+ category="standard"
128
+ name="account"
129
+ size="large"
130
+ />
131
+ )}
132
+ />
133
+ <Checkbox
134
+ labels={{
135
+ label: 'Lead',
136
+ }}
137
+ value="2"
138
+ checked={this.state.checked.includes('2')}
139
+ onChange={() => {
140
+ if (this.state.checked.includes('2'))
141
+ this.setState({
142
+ checked: this.state.checked.filter(
143
+ (item) => item !== '2'
144
+ ),
145
+ });
146
+ else this.setState({ checked: [...this.state.checked, '2'] });
147
+ }}
148
+ id="visual-picker-coverable-checkbox-2"
149
+ onRenderVisualPickerSelected={() => (
150
+ <Icon
151
+ assistiveText={this.props.assistiveText}
152
+ category="utility"
153
+ name="check"
154
+ colorVariant="base"
155
+ size="large"
156
+ />
157
+ )}
158
+ onRenderVisualPickerNotSelected={() => (
159
+ <Icon
160
+ assistiveText={this.props.assistiveText}
161
+ category="standard"
162
+ name="lead"
163
+ size="large"
164
+ />
165
+ )}
166
+ />
167
+ <Checkbox
168
+ labels={{
169
+ label: 'Orders',
170
+ }}
171
+ value="3"
172
+ checked={this.state.checked.includes('3')}
173
+ onChange={() => {
174
+ if (this.state.checked.includes('3'))
175
+ this.setState({
176
+ checked: this.state.checked.filter(
177
+ (item) => item !== '3'
178
+ ),
179
+ });
180
+ else {
181
+ this.setState({ checked: [...this.state.checked, '3'] });
182
+ }
183
+ }}
184
+ id="visual-picker-coverable-checkbox-3"
185
+ onRenderVisualPickerSelected={() => (
186
+ <Icon
187
+ assistiveText={this.props.assistiveText}
188
+ category="utility"
189
+ name="check"
190
+ colorVariant="base"
191
+ size="large"
192
+ />
193
+ )}
194
+ onRenderVisualPickerNotSelected={() => (
195
+ <Icon
196
+ assistiveText={this.props.assistiveText}
197
+ category="standard"
198
+ name="orders"
199
+ size="large"
200
+ />
201
+ )}
202
+ />
203
+ </React.Fragment>
204
+ )}
205
+ </VisualPicker>
206
+ </IconSettings>
207
+ );
208
+ }
209
+ }
210
+
211
+ VisualPickerExample.propTypes = {
212
+ label: PropTypes.string,
213
+ id: PropTypes.string,
214
+ checked: PropTypes.any,
215
+ type: PropTypes.oneOf(['radio', 'checkbox']),
216
+ };
217
+
218
+ VisualPickerExample.defaultProps = {
219
+ type: 'radio',
220
+ checked: null,
221
+ };
222
+
223
+ /* VisualPicker rendering tests
224
+ */
225
+ describe('SLDS Visual Picker', function () {
226
+ let mountNode;
227
+ let wrapper;
228
+
229
+ beforeEach(() => {
230
+ mountNode = createMountNode({ context: this });
231
+ });
232
+
233
+ afterEach(() => {
234
+ destroyMountNode({ wrapper, mountNode });
235
+ });
236
+
237
+ it('radio switching works correctly', () => {
238
+ wrapper = mount(
239
+ <VisualPickerExample label="Select any one" type="radio" checked="1" />,
240
+ { attachTo: mountNode }
241
+ );
242
+ // Get the radio options
243
+ let radio1 = wrapper.find({ value: '1' }).find('input');
244
+ let radio2 = wrapper.find({ value: '2' }).find('input');
245
+ // Check if the first option alone is selected initially
246
+ expect(radio1).to.have.prop('checked', true);
247
+ expect(radio2).to.have.prop('checked', false);
248
+ // Click on radio 2, and switch the option
249
+ radio2.simulate('change');
250
+ // Get both the radios again after the update
251
+ radio1 = wrapper.find({ value: '1' }).find('input');
252
+ radio2 = wrapper.find({ value: '2' }).find('input');
253
+ // Check if only the second option is selected
254
+ expect(radio1).to.have.prop('checked', false);
255
+ expect(radio2).to.have.prop('checked', true);
256
+ });
257
+
258
+ it('checkbox selection works correctly', () => {
259
+ wrapper = mount(
260
+ <VisualPickerExample
261
+ label="Select any one"
262
+ type="checkbox"
263
+ checked={['1']}
264
+ />,
265
+ { attachTo: mountNode }
266
+ );
267
+ // Get the checkbox options
268
+ let cb1 = wrapper.find({ value: '1' }).find('input');
269
+ let cb2 = wrapper.find({ value: '2' }).find('input');
270
+ let cb3 = wrapper.find({ value: '3' }).find('input');
271
+ // Check if the first option alone is selected initially
272
+ expect(cb1).to.have.prop('checked', true);
273
+ expect(cb2).to.have.prop('checked', false);
274
+ expect(cb3).to.have.prop('checked', false);
275
+ // Click on each of the checkbox options
276
+ cb1.simulate('change');
277
+ cb2.simulate('change');
278
+ cb3.simulate('change');
279
+ // Get the checkbox options again after the update
280
+ cb1 = wrapper.find({ value: '1' }).find('input');
281
+ cb2 = wrapper.find({ value: '2' }).find('input');
282
+ cb3 = wrapper.find({ value: '3' }).find('input');
283
+ // Check if all options except first option is selected
284
+ expect(cb1).to.have.prop('checked', false);
285
+ expect(cb2).to.have.prop('checked', true);
286
+ expect(cb3).to.have.prop('checked', true);
287
+ });
288
+ });