@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.
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,308 @@
1
+ /* eslint-disable react/no-find-dom-node */
2
+ import React from 'react';
3
+ import { expect } from 'chai';
4
+
5
+ import SLDSPill from '../../pill';
6
+ import SLDSIcon from '../..//icon';
7
+ import SLDSAvatar from '../..//avatar';
8
+ import {
9
+ mountComponent,
10
+ unmountComponent,
11
+ } from '../../../tests/enzyme-helpers';
12
+
13
+ describe('SLDSPill', () => {
14
+ const LABEL = 'Pill Label';
15
+ const LABEL_TITLE = 'Full pill label verbiage mirrored here';
16
+
17
+ describe('Linked', () => {
18
+ const onClick = sinon.stub();
19
+ const onRemove = sinon.stub();
20
+ const onFocus = sinon.stub();
21
+ const onBlur = sinon.stub();
22
+
23
+ beforeEach(
24
+ mountComponent(
25
+ <SLDSPill
26
+ tabIndex="0"
27
+ labels={{
28
+ label: LABEL,
29
+ title: LABEL_TITLE,
30
+ removeTitle: 'Remove',
31
+ }}
32
+ assistiveText={{
33
+ remove: 'Remove assistive text',
34
+ }}
35
+ className="extra-class"
36
+ onClick={onClick}
37
+ onRemove={onRemove}
38
+ onFocus={onFocus}
39
+ onBlur={onBlur}
40
+ />
41
+ )
42
+ );
43
+
44
+ afterEach(unmountComponent);
45
+
46
+ it('has correct style and attributes', function () {
47
+ expect(this.wrapper).to.have.className('slds-pill');
48
+ expect(this.wrapper).to.have.className('slds-pill_link');
49
+ expect(this.wrapper).to.have.className('extra-class');
50
+ expect(this.wrapper.find('.slds-pill[role="button"]')).to.be.present();
51
+ });
52
+
53
+ it('renders label as a link', function () {
54
+ const anchor = this.wrapper.find('.slds-pill__action');
55
+ expect(anchor.exists()).to.be.true;
56
+ expect(anchor.prop('title')).to.equal(LABEL_TITLE);
57
+ const label = this.wrapper.find('.slds-pill__label');
58
+ expect(label.text()).to.equal(LABEL);
59
+ });
60
+
61
+ it('renders remove button', function () {
62
+ const removeButton = this.wrapper.find('.slds-pill__remove');
63
+ expect(removeButton.exists()).to.be.true;
64
+ });
65
+
66
+ it('renders assistive text in remove button', function () {
67
+ const removeButton = this.wrapper.find('.slds-pill__remove');
68
+ expect(removeButton.exists()).to.be.true;
69
+ const assistiveText = removeButton.find('.slds-assistive-text');
70
+ expect(assistiveText.exists()).to.be.true;
71
+ expect(assistiveText.text()).to.equal('Remove assistive text');
72
+ });
73
+
74
+ it('focuses and blurs', function () {
75
+ this.wrapper.simulate('focus');
76
+ expect(this.wrapper).to.containMatchingElement(document.activeElement);
77
+ expect(onFocus.calledOnce).to.be.true;
78
+ this.wrapper.simulate('blur');
79
+ expect(document.activeElement).to.equal(document.querySelector('body'));
80
+ expect(onBlur.calledOnce).to.be.true;
81
+ });
82
+
83
+ it('reponds to link clicks', function () {
84
+ const pillLink = this.wrapper.find('.slds-pill__action');
85
+ expect(pillLink).to.exist;
86
+ pillLink.simulate('click');
87
+ expect(onClick.calledOnce).to.be.true;
88
+ });
89
+
90
+ it('responds to remove clicks', function () {
91
+ const removeButton = this.wrapper.find('.slds-pill__remove');
92
+ expect(removeButton).to.exist;
93
+ removeButton.simulate('click');
94
+ expect(onRemove.calledOnce).to.be.true;
95
+ });
96
+ });
97
+
98
+ describe('Linked With Href', () => {
99
+ const HREF = 'https://www.salesforce.com';
100
+
101
+ beforeEach(
102
+ mountComponent(
103
+ <SLDSPill
104
+ labels={{
105
+ label: LABEL,
106
+ }}
107
+ href={HREF}
108
+ />
109
+ )
110
+ );
111
+
112
+ afterEach(unmountComponent);
113
+
114
+ it('uses href', function () {
115
+ expect(this.wrapper).to.have.className('slds-pill_link');
116
+ const anchor = this.wrapper.find('.slds-pill__action');
117
+ expect(anchor).to.exist;
118
+ expect(anchor).to.have.prop('href', HREF);
119
+ });
120
+ });
121
+
122
+ describe('Link style on', () => {
123
+ beforeEach(
124
+ mountComponent(
125
+ <SLDSPill
126
+ labels={{
127
+ label: LABEL,
128
+ }}
129
+ />
130
+ )
131
+ );
132
+
133
+ afterEach(unmountComponent);
134
+
135
+ it('forces link style', function () {
136
+ expect(this.wrapper).to.have.className('slds-pill_link');
137
+ const anchor = this.wrapper.find('.slds-pill__action');
138
+ expect(anchor).to.exist;
139
+ });
140
+ });
141
+
142
+ describe('Bare Linked With Role', () => {
143
+ beforeEach(
144
+ mountComponent(
145
+ <SLDSPill
146
+ labels={{
147
+ label: LABEL,
148
+ }}
149
+ bare
150
+ />
151
+ )
152
+ );
153
+
154
+ afterEach(unmountComponent);
155
+
156
+ it('has correct style and attributes', function () {
157
+ expect(this.wrapper).to.have.className('slds-pill');
158
+ expect(this.wrapper).to.have.className('slds-pill_bare');
159
+ expect(this.wrapper.find('.slds-pill[role="button"]').exists()).to.be
160
+ .true;
161
+ });
162
+ });
163
+
164
+ describe('Linked With Error', () => {
165
+ beforeEach(
166
+ mountComponent(
167
+ <SLDSPill
168
+ labels={{
169
+ label: LABEL,
170
+ }}
171
+ hasError
172
+ />
173
+ )
174
+ );
175
+
176
+ afterEach(unmountComponent);
177
+
178
+ it('has correct style and attributes', function () {
179
+ expect(this.wrapper).to.have.className('slds-has-error');
180
+ });
181
+ });
182
+
183
+ describe('Linked With Icon', () => {
184
+ const onClick = sinon.stub();
185
+
186
+ beforeEach(
187
+ mountComponent(
188
+ <SLDSPill
189
+ labels={{
190
+ label: LABEL,
191
+ }}
192
+ onClick={onClick}
193
+ icon={<SLDSIcon title="Account" category="standard" name="account" />}
194
+ />
195
+ )
196
+ );
197
+
198
+ afterEach(unmountComponent);
199
+
200
+ it('renders icon to the left from label', function () {
201
+ const icon = this.wrapper.find(SLDSIcon);
202
+ expect(icon.exists()).to.be.true;
203
+ expect(icon.prop('title')).to.equal('Account');
204
+ expect(icon.prop('category')).to.equal('standard');
205
+ expect(icon.prop('name')).to.equal('account');
206
+ });
207
+ });
208
+
209
+ describe('Linked With Avatar', () => {
210
+ beforeEach(
211
+ mountComponent(
212
+ <SLDSPill
213
+ labels={{
214
+ label: LABEL,
215
+ }}
216
+ avatar={
217
+ <SLDSAvatar
218
+ variant="user"
219
+ title="User avatar"
220
+ imgSrc="https://lightningdesignsystem.com/assets/images/avatar2.jpg"
221
+ />
222
+ }
223
+ />
224
+ )
225
+ );
226
+
227
+ afterEach(unmountComponent);
228
+
229
+ it('renders icon to the left from label', function () {
230
+ const avatar = this.wrapper.find(SLDSAvatar);
231
+ expect(avatar.exists()).to.be.true;
232
+ expect(avatar.prop('title')).to.equal('User avatar');
233
+ expect(avatar.prop('variant')).to.equal('user');
234
+ expect(avatar.prop('imgSrc')).to.equal(
235
+ 'https://lightningdesignsystem.com/assets/images/avatar2.jpg'
236
+ );
237
+ });
238
+ });
239
+
240
+ describe('Option', () => {
241
+ const onRemove = sinon.stub();
242
+
243
+ beforeEach(
244
+ mountComponent(
245
+ <SLDSPill
246
+ labels={{
247
+ label: LABEL,
248
+ title: LABEL_TITLE,
249
+ removeTitle: 'Remove',
250
+ }}
251
+ variant="option"
252
+ onRemove={onRemove}
253
+ />
254
+ )
255
+ );
256
+
257
+ afterEach(unmountComponent);
258
+
259
+ it('has correct style', function () {
260
+ expect(this.wrapper).to.have.className('slds-pill');
261
+ expect(this.wrapper).to.not.have.className('slds-pill_link');
262
+ const anchor = this.wrapper.find('.slds-pill__action');
263
+ expect(anchor).to.not.exist;
264
+ });
265
+ });
266
+
267
+ describe('Linked Custom', () => {
268
+ const onClick = sinon.stub();
269
+ const onRemove = sinon.stub();
270
+
271
+ beforeEach(
272
+ mountComponent(
273
+ <SLDSPill onClick={onClick} onRemove={onRemove}>
274
+ <div className="abc">this is a custom label</div>
275
+ </SLDSPill>
276
+ )
277
+ );
278
+
279
+ afterEach(unmountComponent);
280
+
281
+ it('has correct style', function () {
282
+ expect(this.wrapper).to.have.className('slds-pill');
283
+ expect(this.wrapper).to.have.className('slds-pill_link');
284
+ const child = this.wrapper.find('.abc');
285
+ expect(child.exists()).to.be.true;
286
+ expect(child.text()).to.equal('this is a custom label');
287
+ });
288
+
289
+ it('renders remove button', function () {
290
+ const removeButton = this.wrapper.find('.slds-pill__remove');
291
+ expect(removeButton.exists()).to.be.true;
292
+ });
293
+
294
+ it('reponds to link clicks', function () {
295
+ const pillLink = this.wrapper.find('.slds-pill');
296
+ expect(pillLink).to.exist;
297
+ pillLink.simulate('click');
298
+ expect(onClick.calledOnce).to.be.true;
299
+ });
300
+
301
+ it('responds to remove clicks', function () {
302
+ const removeButton = this.wrapper.find('.slds-pill__remove');
303
+ expect(removeButton).to.exist;
304
+ removeButton.simulate('click');
305
+ expect(onRemove.calledOnce).to.be.true;
306
+ });
307
+ });
308
+ });
@@ -0,0 +1,186 @@
1
+ /* eslint-disable react/no-find-dom-node */
2
+ import React from 'react';
3
+ import TestUtils from 'react-dom/test-utils';
4
+ import { expect } from 'chai';
5
+
6
+ import Avatar from '../../avatar';
7
+ import Icon from '../../icon';
8
+ import IconSettings from '../../icon-settings';
9
+ import SLDSPillContainer from '../../pill-container';
10
+ import {
11
+ mountComponent,
12
+ unmountComponent,
13
+ } from '../../../tests/enzyme-helpers';
14
+ import { keyObjects } from '../../../utilities/key-code';
15
+
16
+ const { Simulate } = TestUtils;
17
+
18
+ const options = [
19
+ {
20
+ id: '1',
21
+ label: 'Pill Label 1',
22
+ title: 'Full pill label verbiage mirrored here',
23
+ },
24
+ {
25
+ icon: <Icon category="standard" name="account" title="Account" />,
26
+ id: '2',
27
+ label: 'Pill Label 2',
28
+ title: 'Full pill label verbiage mirrored here',
29
+ },
30
+ {
31
+ icon: {
32
+ category: 'standard',
33
+ name: 'account',
34
+ },
35
+ id: '3',
36
+ label: 'Pill Label 3',
37
+ title: 'Full pill label verbiage mirrored here',
38
+ },
39
+ {
40
+ avatar: (
41
+ <Avatar
42
+ imgSrc="https://lightningdesignsystem.com/assets/images/avatar1.jpg"
43
+ title="User 4"
44
+ variant="user"
45
+ />
46
+ ),
47
+ id: '4',
48
+ label: 'Pill Label 4',
49
+ title: 'Full pill label verbiage mirrored here',
50
+ },
51
+ {
52
+ avatar: {
53
+ imgSrc: 'https://lightningdesignsystem.com/assets/images/avatar1.jpg',
54
+ title: 'User 5',
55
+ },
56
+ id: '5',
57
+ label: 'Pill Label 5',
58
+ title: 'Full pill label verbiage mirrored here',
59
+ },
60
+ {
61
+ bare: true,
62
+ id: '6',
63
+ label: 'Pill Label 6',
64
+ title: 'Full pill label verbiage mirrored here',
65
+ },
66
+ {
67
+ error: true,
68
+ id: '7',
69
+ label: 'Pill Label 7',
70
+ title: 'Full pill label verbiage mirrored here',
71
+ },
72
+ ];
73
+
74
+ describe('SLDSPillContainer', () => {
75
+ describe('Base', () => {
76
+ let clickData = {};
77
+ let requestRemoveData = {};
78
+
79
+ beforeEach(
80
+ mountComponent(
81
+ <IconSettings iconPath="/assets/icons">
82
+ <SLDSPillContainer
83
+ options={options}
84
+ onClickPill={(event, data) => {
85
+ clickData = data;
86
+ }}
87
+ onRequestRemovePill={(event, data) => {
88
+ requestRemoveData = data;
89
+ }}
90
+ />
91
+ </IconSettings>
92
+ )
93
+ );
94
+
95
+ afterEach(unmountComponent);
96
+
97
+ it('Renders the base Pill Container correctly', function () {
98
+ let idOfCurrentPill = 1;
99
+
100
+ expect(this.wrapper.find('.slds-pill_container').length).to.eql(1);
101
+ expect(this.wrapper.find('ul.slds-listbox').length).to.eql(1);
102
+
103
+ this.wrapper.find('ul.slds-listbox .slds-pill').forEach((pill) => {
104
+ expect(pill.find('.slds-pill__label').text()).to.eql(
105
+ `Pill Label ${idOfCurrentPill}`
106
+ );
107
+
108
+ Simulate.click(pill.getDOMNode());
109
+ expect(clickData.option.id).to.eql(`${idOfCurrentPill}`);
110
+
111
+ Simulate.click(pill.find('.slds-pill__remove').getDOMNode());
112
+ expect(requestRemoveData.option.id).to.eql(`${idOfCurrentPill}`);
113
+
114
+ if (idOfCurrentPill === 2 || idOfCurrentPill === 3) {
115
+ expect(
116
+ pill.find('.slds-icon_container.slds-icon-standard-account').length
117
+ ).to.eql(1);
118
+ } else if (idOfCurrentPill === 4 || idOfCurrentPill === 5) {
119
+ expect(
120
+ pill.find('.slds-avatar.slds-avatar_circle.slds-avatar_medium')
121
+ .length
122
+ ).to.eql(1);
123
+ } else if (idOfCurrentPill === 6) {
124
+ expect(pill.find('.slds-pill_bare').length).to.eql(1);
125
+ } else if (idOfCurrentPill === 7) {
126
+ expect(pill.find('.slds-has-error').length).to.eql(1);
127
+ }
128
+
129
+ idOfCurrentPill += 1;
130
+ });
131
+ });
132
+
133
+ it('Handles keyboard navigation properly', function () {
134
+ const getFocusedPillLabel = () =>
135
+ document.activeElement.querySelector('.slds-pill__label').innerText;
136
+ let i = 1;
137
+
138
+ Simulate.focus(
139
+ this.wrapper
140
+ .find('.slds-pill_container')
141
+ .find('.slds-pill')
142
+ .first()
143
+ .getDOMNode()
144
+ );
145
+
146
+ for (i = 1; i < 7; i += 1) {
147
+ Simulate.keyDown(document.activeElement, keyObjects.RIGHT);
148
+ expect(getFocusedPillLabel()).to.eql(options[i].label);
149
+ }
150
+
151
+ Simulate.keyDown(document.activeElement, keyObjects.RIGHT);
152
+ expect(getFocusedPillLabel()).to.eql(options[0].label);
153
+
154
+ Simulate.keyDown(document.activeElement, keyObjects.LEFT);
155
+ expect(getFocusedPillLabel()).to.eql(options[6].label);
156
+
157
+ for (i = 0; i < 3; i += 1) {
158
+ Simulate.keyDown(document.activeElement, keyObjects.LEFT);
159
+ }
160
+ Simulate.keyDown(document.activeElement, keyObjects.DELETE);
161
+ expect(requestRemoveData.option.label).to.eql(options[3].label);
162
+
163
+ Simulate.keyDown(document.activeElement, keyObjects.LEFT);
164
+ Simulate.keyDown(document.activeElement, keyObjects.BACKSPACE);
165
+ expect(requestRemoveData.option.label).to.eql(options[2].label);
166
+ });
167
+ });
168
+
169
+ describe('Bare', () => {
170
+ beforeEach(
171
+ mountComponent(
172
+ <IconSettings iconPath="/assets/icons">
173
+ <SLDSPillContainer options={options} variant="bare" />
174
+ </IconSettings>
175
+ )
176
+ );
177
+
178
+ afterEach(unmountComponent);
179
+
180
+ it('Renders the bare Pill Container correctly', function () {
181
+ this.wrapper.find('ul.slds-listbox .slds-pill').forEach((pill) => {
182
+ expect(pill.find('.slds-pill_bare').length).to.eql(1);
183
+ });
184
+ });
185
+ });
186
+ });