@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,207 @@
1
+ /* eslint-disable react/no-render-return-value */
2
+ /* eslint-disable react/no-find-dom-node */
3
+
4
+ import React from 'react';
5
+ import { mount } from 'enzyme';
6
+ import chai, { expect } from 'chai';
7
+ import chaiEnzyme from 'chai-enzyme';
8
+ import {
9
+ createMountNode,
10
+ destroyMountNode,
11
+ } from '../../../tests/enzyme-helpers';
12
+
13
+ import SLDSAvatar from '../../avatar';
14
+ import IconSettings from '../../icon-settings';
15
+
16
+ chai.use(chaiEnzyme());
17
+
18
+ describe('SLDSAvatar: ', function describeFunction() {
19
+ let mountNode;
20
+ let wrapper;
21
+
22
+ describe('Default Structure', function describeFunction2() {
23
+ beforeEach(() => {
24
+ mountNode = createMountNode({ context: this });
25
+ });
26
+
27
+ afterEach(() => {
28
+ destroyMountNode({ wrapper, mountNode });
29
+ });
30
+
31
+ it('avatar renders with image', () => {
32
+ const expectedSrc = 'assets/images/global-header/logo.svg';
33
+ wrapper = mount(<SLDSAvatar imgSrc={expectedSrc} />, {
34
+ attachTo: mountNode,
35
+ });
36
+
37
+ const img = wrapper.find('img');
38
+ const src = img.prop('src');
39
+ expect(src).to.equal(expectedSrc);
40
+ });
41
+
42
+ it('renders proper icon size class', () => {
43
+ wrapper = mount(
44
+ <IconSettings iconPath="/assets/icons">
45
+ <SLDSAvatar size="large" />
46
+ </IconSettings>,
47
+ { attachTo: mountNode }
48
+ );
49
+
50
+ const avatar = wrapper.find('.slds-avatar_large');
51
+ expect(avatar).to.be.present;
52
+ });
53
+
54
+ describe('variant is a user', () => {
55
+ beforeEach(() => {
56
+ wrapper = mount(
57
+ <IconSettings iconPath="/assets/icons">
58
+ <SLDSAvatar variant="user" />
59
+ </IconSettings>,
60
+ { attachTo: mountNode }
61
+ );
62
+ });
63
+
64
+ it('displays as a circle', () => {
65
+ const circleClass = !!wrapper.find('.slds-avatar_circle');
66
+ expect(circleClass).to.be.true;
67
+ });
68
+ });
69
+
70
+ describe('variant is an entity', () => {
71
+ beforeEach(() => {
72
+ wrapper = mount(
73
+ <IconSettings iconPath="/assets/icons">
74
+ <SLDSAvatar variant="entity" />
75
+ </IconSettings>,
76
+ { attachTo: mountNode }
77
+ );
78
+ });
79
+
80
+ it('displays as a square (no circle class)', () => {
81
+ const avatar = wrapper.find('.slds-avatar_circle');
82
+ expect(avatar).to.not.be.present;
83
+ });
84
+ });
85
+ });
86
+
87
+ describe('Initials avatar fallback check', () => {
88
+ beforeEach(() => {
89
+ mountNode = createMountNode({ context: this });
90
+ });
91
+
92
+ afterEach(() => {
93
+ destroyMountNode({ wrapper, mountNode });
94
+ });
95
+
96
+ it('renders "initials prop" initials if they are passed in directly', () => {
97
+ wrapper = mount(
98
+ <IconSettings iconPath="/assets/icons">
99
+ <SLDSAvatar initials="AW" />
100
+ </IconSettings>,
101
+ { attachTo: mountNode }
102
+ );
103
+
104
+ const abbr = wrapper.find('abbr');
105
+ expect(abbr.text()).to.equal('AW');
106
+ });
107
+
108
+ it('renders fallback initials abbr node if initials or label prop exists', () => {
109
+ wrapper = mount(
110
+ <IconSettings iconPath="/assets/icons">
111
+ <SLDSAvatar label="test" />
112
+ </IconSettings>,
113
+ { attachTo: mountNode }
114
+ );
115
+ const abbr = !!wrapper.find('abbr');
116
+ expect(abbr).to.be.true;
117
+ });
118
+
119
+ it('calls buildInitials in abbr node if no initials prop', () => {
120
+ wrapper = mount(
121
+ <IconSettings iconPath="/assets/icons">
122
+ <SLDSAvatar label="Jane Doe" />
123
+ </IconSettings>,
124
+ { attachTo: mountNode }
125
+ );
126
+ const abbr = wrapper.find('abbr');
127
+ expect(abbr.text()).to.equal('JD');
128
+ });
129
+
130
+ it('renders first two letters of one word if label is one word', () => {
131
+ wrapper = mount(
132
+ <IconSettings iconPath="/assets/icons">
133
+ <SLDSAvatar label="Acme" />
134
+ </IconSettings>,
135
+ { attachTo: mountNode }
136
+ );
137
+ const abbr = wrapper.find('abbr');
138
+ expect(abbr.text()).to.equal('Ac');
139
+ });
140
+
141
+ it('renders first letters of each word if label is two words', () => {
142
+ wrapper = mount(
143
+ <IconSettings iconPath="/assets/icons">
144
+ <SLDSAvatar label="Acme Communications" />
145
+ </IconSettings>,
146
+ { attachTo: mountNode }
147
+ );
148
+ const abbr = wrapper.find('abbr');
149
+ expect(abbr.text()).to.equal('AC');
150
+ });
151
+
152
+ it('renders first letters of first and last word if label is more than two words', () => {
153
+ wrapper = mount(
154
+ <IconSettings iconPath="/assets/icons">
155
+ <SLDSAvatar label="Acme Communications Inc." />
156
+ </IconSettings>,
157
+ { attachTo: mountNode }
158
+ );
159
+ const abbr = wrapper.find('abbr');
160
+ expect(abbr.text()).to.equal('AI');
161
+ });
162
+ });
163
+
164
+ describe('Icon avatar fallback check', () => {
165
+ beforeEach(() => {
166
+ mountNode = createMountNode({ context: this });
167
+ });
168
+
169
+ afterEach(() => {
170
+ destroyMountNode({ wrapper, mountNode });
171
+ });
172
+
173
+ it('renders expected assistiveText', () => {
174
+ wrapper = mount(
175
+ <IconSettings iconPath="/assets/icons">
176
+ <SLDSAvatar
177
+ variant="entity"
178
+ assistiveText={{ icon: 'entity icon avatar' }}
179
+ />
180
+ </IconSettings>,
181
+ { attachTo: mountNode }
182
+ );
183
+ const span = wrapper.find('.slds-assistive-text');
184
+ expect(span.text()).to.equal('entity icon avatar');
185
+ });
186
+
187
+ it('renders account icon', () => {
188
+ wrapper = mount(
189
+ <IconSettings iconPath="/assets/icons">
190
+ <SLDSAvatar variant="entity" />
191
+ </IconSettings>,
192
+ { attachTo: mountNode }
193
+ );
194
+ expect(wrapper.find('.slds-icon-standard-account')).to.be.present;
195
+ });
196
+
197
+ it('renders user icon', () => {
198
+ wrapper = mount(
199
+ <IconSettings iconPath="/assets/icons">
200
+ <SLDSAvatar variant="user" />
201
+ </IconSettings>,
202
+ { attachTo: mountNode }
203
+ );
204
+ expect(wrapper.find('.slds-icon-standard-user')).to.be.present;
205
+ });
206
+ });
207
+ });
@@ -0,0 +1,53 @@
1
+ /* eslint-disable react/no-render-return-value */
2
+ /* eslint-disable react/no-find-dom-node */
3
+ import React from 'react';
4
+ import ReactDOM from 'react-dom';
5
+ import TestUtils from 'react-dom/test-utils';
6
+ import { expect } from 'chai';
7
+
8
+ import BuilderHeader from '../../builder-header';
9
+ import IconSettings from '../../icon-settings';
10
+
11
+ describe('SLDSBuilderHeader: ', () => {
12
+ let clicked;
13
+ const setClick = () => {
14
+ clicked = true;
15
+ };
16
+
17
+ const renderBuilderHeader = () => {
18
+ const ref = React.createRef();
19
+ TestUtils.renderIntoDocument(
20
+ <IconSettings iconPath="/assets/icons">
21
+ <div ref={ref}>
22
+ <BuilderHeader
23
+ events={{ onClickBack: setClick, onClickHelp: setClick }}
24
+ />
25
+ </div>
26
+ </IconSettings>
27
+ );
28
+ return ReactDOM.findDOMNode(ref.current);
29
+ };
30
+
31
+ describe('Links are clickable', () => {
32
+ let cmp;
33
+ let links;
34
+
35
+ beforeEach(() => {
36
+ clicked = false;
37
+ cmp = renderBuilderHeader();
38
+ links = cmp.getElementsByClassName('slds-builder-header__item-action');
39
+ });
40
+
41
+ it('triggers when Back link is clicked', () => {
42
+ expect(clicked).to.be.false;
43
+ TestUtils.Simulate.click(links[0], {});
44
+ expect(clicked).to.be.true;
45
+ });
46
+
47
+ it('triggers when Help link is clicked', () => {
48
+ expect(clicked).to.be.false;
49
+ TestUtils.Simulate.click(links[1], {});
50
+ expect(clicked).to.be.true;
51
+ });
52
+ });
53
+ });
@@ -0,0 +1,226 @@
1
+ /* eslint-disable react/no-render-return-value */
2
+ /* eslint-disable react/no-find-dom-node */
3
+ import React from 'react';
4
+ import ReactDOM from 'react-dom';
5
+ import TestUtils from 'react-dom/test-utils';
6
+ import { expect } from 'chai';
7
+ import assign from 'lodash.assign';
8
+
9
+ import SLDSButton from '../../button';
10
+ import IconSettings from '../../icon-settings';
11
+
12
+ const { Simulate } = TestUtils;
13
+
14
+ const mockCallback = sinon.spy();
15
+
16
+ describe('SLDSButton: ', () => {
17
+ const defaultProps = {
18
+ label: 'Neutral',
19
+ onClick: mockCallback,
20
+ variant: 'neutral',
21
+ };
22
+
23
+ const renderButton = (instance) => {
24
+ const ref = React.createRef();
25
+ TestUtils.renderIntoDocument(
26
+ <IconSettings iconPath="/assets/icons">
27
+ <div ref={ref}>{instance}</div>
28
+ </IconSettings>
29
+ );
30
+ return ReactDOM.findDOMNode(ref.current);
31
+ };
32
+
33
+ const createButton = (props) =>
34
+ React.createElement(SLDSButton, assign({}, defaultProps, props));
35
+ const getButton = (props) => renderButton(createButton(props));
36
+
37
+ describe('Basic Button Props Render', () => {
38
+ let cmp;
39
+ let btn;
40
+
41
+ beforeEach(() => {
42
+ cmp = getButton({
43
+ id: 'custom-id',
44
+ text: 'Brand',
45
+ theme: 'brand',
46
+ style: { background: 'rgb(18, 49, 35)' },
47
+ });
48
+ [btn] = cmp.getElementsByClassName('slds-button');
49
+ });
50
+
51
+ it('renders correct label', () => {
52
+ expect(btn.textContent).to.equal('Neutral');
53
+ });
54
+
55
+ it('renders correct variant styles', () => {
56
+ expect(btn.className).to.include('slds-button_neutral');
57
+ });
58
+
59
+ it('renders custom id', () => {
60
+ expect(btn.getAttribute('id')).to.equal('custom-id');
61
+ });
62
+
63
+ it('renders custom styles', function () {
64
+ btn.style.backgroundColor.should.equal('rgb(18, 49, 35)');
65
+ });
66
+ });
67
+
68
+ describe('Form Props Render ', () => {
69
+ let cmp;
70
+ let btn;
71
+ const formAction = 'http://localhost/some/url';
72
+
73
+ beforeEach(() => {
74
+ cmp = getButton({
75
+ id: 'custom-id',
76
+ formAction,
77
+ });
78
+ [btn] = cmp.getElementsByClassName('slds-button');
79
+ });
80
+
81
+ it('renders formAction prop', () => {
82
+ expect(btn.formAction).to.equal(formAction);
83
+ });
84
+ });
85
+
86
+ describe('Data Props Render ', () => {
87
+ let cmp;
88
+ let btn;
89
+
90
+ beforeEach(() => {
91
+ cmp = getButton({
92
+ id: 'custom-id',
93
+ 'data-some-attribute': 'some value',
94
+ });
95
+ [btn] = cmp.getElementsByClassName('slds-button');
96
+ });
97
+
98
+ it('renders data-some-attribute prop', () => {
99
+ expect(btn.getAttribute('data-some-attribute')).to.equal('some value');
100
+ });
101
+ });
102
+
103
+ describe('Icon with Label Button Props Render', () => {
104
+ let cmp;
105
+ let btn;
106
+ let svg;
107
+
108
+ beforeEach(() => {
109
+ cmp = getButton({
110
+ label: 'Neutral with Icon',
111
+ iconName: 'download',
112
+ iconCategory: 'action',
113
+ iconPosition: 'right',
114
+ variant: 'neutral',
115
+ });
116
+ [btn] = cmp.getElementsByClassName('slds-button');
117
+ [svg] = cmp.getElementsByClassName('slds-button__icon');
118
+ });
119
+
120
+ it('renders label', () => {
121
+ expect(btn.textContent).to.equal('Neutral with Icon');
122
+ });
123
+
124
+ it('renders icon', () => {
125
+ expect(svg.className.baseVal).to.include('slds-button__icon_right');
126
+ });
127
+ });
128
+
129
+ describe('Icon Button Props render', () => {
130
+ let cmp;
131
+ let asstText;
132
+ let svg;
133
+
134
+ beforeEach(() => {
135
+ cmp = getButton({
136
+ assistiveText: { icon: 'my settings' },
137
+ variant: 'icon',
138
+ iconCategory: 'utility',
139
+ iconName: 'settings',
140
+ iconSize: 'small',
141
+ iconVariant: 'bare',
142
+ });
143
+ [asstText] = cmp.getElementsByClassName('slds-assistive-text');
144
+ [svg] = cmp.getElementsByTagName('svg');
145
+ });
146
+
147
+ it('renders label', () => {
148
+ expect(asstText.textContent).to.equal('my settings');
149
+ });
150
+
151
+ it('renders icon styles', () => {
152
+ expect(svg.className.baseVal).to.include('slds-button__icon');
153
+ });
154
+ });
155
+
156
+ describe('(icon path) Icon Button renders assistive text', () => {
157
+ let cmp;
158
+ let asstText;
159
+
160
+ beforeEach(() => {
161
+ cmp = getButton({
162
+ assistiveText: { icon: 'News' },
163
+ iconSize: 'large',
164
+ iconPath: '/assets/icons/utility-sprite/svg/symbols.svg#announcement',
165
+ title: 'announcement',
166
+ });
167
+ [asstText] = cmp.getElementsByClassName('slds-assistive-text');
168
+ });
169
+
170
+ it('renders label', () => {
171
+ expect(asstText.textContent).to.equal('News');
172
+ });
173
+ });
174
+
175
+ describe('External Path Icon Button renders', () => {
176
+ let cmp;
177
+ let use;
178
+ let svgHref;
179
+
180
+ before(() => {
181
+ cmp = getButton({
182
+ assistiveText: { icon: 'announcement' },
183
+ variant: 'icon',
184
+ iconPath: '/assets/icons/utility-sprite/svg/symbols.svg#announcement',
185
+ iconSize: 'large',
186
+ iconVariant: 'bare',
187
+ });
188
+ [use] = cmp.getElementsByTagName('use');
189
+ svgHref = use.getAttribute('href');
190
+ });
191
+
192
+ it('renders svg', () => {
193
+ expect(svgHref).to.equal(
194
+ '/assets/icons/utility-sprite/svg/symbols.svg#announcement'
195
+ );
196
+ });
197
+ });
198
+
199
+ describe('Button Clickable', () => {
200
+ let cmp;
201
+ let btn;
202
+ let clicked;
203
+
204
+ function setClick() {
205
+ clicked = true;
206
+ }
207
+
208
+ beforeEach(() => {
209
+ clicked = false;
210
+ cmp = getButton({
211
+ label: 'Neutral',
212
+ variant: 'neutral',
213
+ onClick: setClick,
214
+ });
215
+ [btn] = cmp.getElementsByClassName('slds-button');
216
+ });
217
+
218
+ it('can be clicked', () => {
219
+ /* eslint-disable no-unused-expressions */
220
+ expect(clicked).to.be.false;
221
+ Simulate.click(btn, {});
222
+ expect(clicked).to.be.true;
223
+ /* eslint-enable no-unused-expressions */
224
+ });
225
+ });
226
+ });
@@ -0,0 +1,144 @@
1
+ /* eslint-disable react/no-render-return-value */
2
+ /* eslint-disable react/no-find-dom-node */
3
+
4
+ import React from 'react';
5
+ import ReactDOM from 'react-dom';
6
+
7
+ import TestUtils from 'react-dom/test-utils';
8
+ import { expect } from 'chai';
9
+
10
+ import IconSettings from '../../icon-settings';
11
+ import SLDSButtonGroup from '../../button-group';
12
+ import SLDSButton from '../../button';
13
+
14
+ describe('SLDSButtonGroup: ', () => {
15
+ const generateButtonGroup = (buttonGroupInstance) => {
16
+ const ref = React.createRef();
17
+ TestUtils.renderIntoDocument(
18
+ <IconSettings iconPath="/assets/icons">
19
+ <div ref={ref}>{buttonGroupInstance}</div>
20
+ </IconSettings>
21
+ );
22
+ return ReactDOM.findDOMNode(ref.current);
23
+ };
24
+
25
+ describe('component renders', () => {
26
+ it('buttonGroup renders', () => {
27
+ const instance = (
28
+ <SLDSButtonGroup>
29
+ <SLDSButton
30
+ label="Chart"
31
+ variant="icon"
32
+ iconCategory="utility"
33
+ iconName="chart"
34
+ iconVariant="border"
35
+ />
36
+ <SLDSButton
37
+ label="Filter"
38
+ variant="icon"
39
+ iconCategory="utility"
40
+ iconName="filter"
41
+ iconVariant="border"
42
+ />
43
+ <SLDSButton
44
+ label="Sort"
45
+ variant="icon"
46
+ iconCategory="utility"
47
+ iconName="sort"
48
+ iconVariant="more"
49
+ />
50
+ </SLDSButtonGroup>
51
+ );
52
+ const buttonGroup = generateButtonGroup(instance);
53
+ expect(buttonGroup).to.not.equal(undefined);
54
+ });
55
+
56
+ it('renders proper attributes', () => {
57
+ const instance = (
58
+ <SLDSButtonGroup>
59
+ <SLDSButton
60
+ label="Chart"
61
+ variant="icon"
62
+ iconCategory="utility"
63
+ iconName="chart"
64
+ iconVariant="border"
65
+ />
66
+ <SLDSButton
67
+ label="Filter"
68
+ variant="icon"
69
+ iconCategory="utility"
70
+ iconName="filter"
71
+ iconVariant="border"
72
+ />
73
+ <SLDSButton
74
+ label="Sort"
75
+ variant="icon"
76
+ iconCategory="utility"
77
+ iconName="sort"
78
+ iconVariant="more"
79
+ />
80
+ </SLDSButtonGroup>
81
+ );
82
+ const [buttonGroupElement] = generateButtonGroup(
83
+ instance
84
+ ).getElementsByClassName('slds-button-group');
85
+ const role = buttonGroupElement.getAttribute('role');
86
+ expect(role).to.equal('group');
87
+ });
88
+
89
+ it('renders children', () => {
90
+ const instance = (
91
+ <SLDSButtonGroup>
92
+ <SLDSButton
93
+ label="Chart"
94
+ variant="icon"
95
+ iconCategory="utility"
96
+ iconName="chart"
97
+ iconVariant="border"
98
+ />
99
+ <SLDSButton
100
+ label="Filter"
101
+ variant="icon"
102
+ iconCategory="utility"
103
+ iconName="filter"
104
+ iconVariant="border"
105
+ />
106
+ <SLDSButton
107
+ label="Sort"
108
+ variant="icon"
109
+ iconCategory="utility"
110
+ iconName="sort"
111
+ iconVariant="more"
112
+ />
113
+ </SLDSButtonGroup>
114
+ );
115
+ const buttonGroup = generateButtonGroup(instance);
116
+ const children = buttonGroup.getElementsByTagName('button');
117
+ expect(children.length).to.equal(3);
118
+ });
119
+ });
120
+
121
+ describe('component behavior works', () => {
122
+ it('first button in group invokes method from props', () => {
123
+ const onClick = sinon.spy();
124
+ const instance = (
125
+ <SLDSButtonGroup>
126
+ <SLDSButton label="Refresh" variant="neutral" onClick={onClick} />
127
+ <SLDSButton label="Edit" variant="neutral" />
128
+ <SLDSButton label="Save" variant="neutral" />
129
+ <SLDSButton
130
+ label="More Options"
131
+ variant="icon"
132
+ iconCategory="utility"
133
+ iconName="down"
134
+ iconVariant="border-filled"
135
+ />
136
+ </SLDSButtonGroup>
137
+ );
138
+ const buttonGroup = generateButtonGroup(instance);
139
+ const firstBtn = buttonGroup.getElementsByTagName('button')[0];
140
+ TestUtils.Simulate.click(firstBtn);
141
+ expect(onClick.calledOnce).to.be.true;
142
+ });
143
+ });
144
+ });