@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,177 @@
1
+ /* eslint-disable react/no-find-dom-node */
2
+ import React from 'react';
3
+ import { expect } from 'chai';
4
+
5
+ import SLDSCombobox from '../../combobox';
6
+ import SLDSIconSettings from '../../icon-settings';
7
+ import SLDSGlobalHeader from '../../global-header';
8
+ import SLDSGlobalHeaderFavorites from '../../global-header/favorites';
9
+ import SLDSGlobalHeaderHelp from '../../global-header/help';
10
+ import SLDSGlobalHeaderNotifications from '../../global-header/notifications';
11
+ import SLDSGlobalHeaderProfile from '../../global-header/profile';
12
+ import SLDSGlobalHeaderSearch from '../../global-header/search';
13
+ import SLDSGlobalHeaderSetup from '../../global-header/setup';
14
+ import SLDSGlobalHeaderTask from '../../global-header/task';
15
+
16
+ import {
17
+ mountComponent,
18
+ unmountComponent,
19
+ } from '../../../tests/enzyme-helpers';
20
+
21
+ describe('SLDSGlobalHeader', () => {
22
+ describe('SLDSGlobalHeader index', () => {
23
+ beforeEach(
24
+ mountComponent(
25
+ <SLDSIconSettings iconPath="/assets/icons">
26
+ <SLDSGlobalHeader>
27
+ <SLDSGlobalHeaderProfile />
28
+ <SLDSGlobalHeaderSetup />
29
+ <SLDSGlobalHeaderFavorites />
30
+ <SLDSGlobalHeaderTask />
31
+ <SLDSGlobalHeaderNotifications />
32
+ <SLDSGlobalHeaderSearch
33
+ combobox={
34
+ <SLDSCombobox
35
+ assistiveText={{ label: 'Search' }}
36
+ id="global-header-search-combobox-test"
37
+ labels={{ placeholder: 'Search Salesforce' }}
38
+ options={[]}
39
+ />
40
+ }
41
+ />
42
+ <SLDSGlobalHeaderHelp />
43
+ </SLDSGlobalHeader>
44
+ </SLDSIconSettings>
45
+ )
46
+ );
47
+
48
+ afterEach(unmountComponent);
49
+
50
+ it('arranges components correctly even if the developer put them out of order', function () {
51
+ const order = [
52
+ 'div.slds-global-actions__favorites',
53
+ 'button.slds-global-actions__task',
54
+ 'button.slds-global-actions__help',
55
+ 'button.slds-global-actions__setup',
56
+ 'button.slds-global-actions__notifications',
57
+ 'button.slds-global-actions__avatar',
58
+ ];
59
+
60
+ this.wrapper
61
+ .find('ul.slds-global-actions li.slds-global-actions__item')
62
+ .forEach((node, index) => {
63
+ expect(node.find(order[index]).length).to.eql(1);
64
+ });
65
+ });
66
+ });
67
+
68
+ describe('SLDSGlobalHeaderFavorites', () => {
69
+ it('handles actionDisabled correctly', function () {
70
+ mountComponent(
71
+ <SLDSIconSettings iconPath="/assets/icons">
72
+ <SLDSGlobalHeader>
73
+ <SLDSGlobalHeaderFavorites actionDisabled />
74
+ </SLDSGlobalHeader>
75
+ </SLDSIconSettings>
76
+ ).call(this);
77
+
78
+ const actionButtonSelector =
79
+ 'button.slds-global-actions__favorites-action';
80
+
81
+ expect(
82
+ this.wrapper.find(actionButtonSelector).hasClass('slds-is-disabled')
83
+ ).to.eql(true);
84
+ expect(
85
+ this.wrapper.find(`${actionButtonSelector}[disabled=true]`).length
86
+ ).to.eql(1);
87
+
88
+ unmountComponent.call(this);
89
+ });
90
+
91
+ it('handles actionSelected correctly', function () {
92
+ mountComponent(
93
+ <SLDSIconSettings iconPath="/assets/icons">
94
+ <SLDSGlobalHeader>
95
+ <SLDSGlobalHeaderFavorites actionSelected />
96
+ </SLDSGlobalHeader>
97
+ </SLDSIconSettings>
98
+ ).call(this);
99
+
100
+ const actionButtonSelector =
101
+ 'button.slds-global-actions__favorites-action';
102
+
103
+ expect(
104
+ this.wrapper.find(actionButtonSelector).hasClass('slds-is-selected')
105
+ ).to.eql(true);
106
+ expect(
107
+ this.wrapper.find(`${actionButtonSelector}[aria-pressed=true]`).length
108
+ ).to.eql(1);
109
+
110
+ unmountComponent.call(this);
111
+ });
112
+
113
+ it('handles onToggleActionSelected correctly', function () {
114
+ let args = {};
115
+
116
+ mountComponent(
117
+ <SLDSIconSettings iconPath="/assets/icons">
118
+ <SLDSGlobalHeader>
119
+ <SLDSGlobalHeaderFavorites
120
+ onToggleActionSelected={(event, data) => {
121
+ args.event = event;
122
+ args.data = data;
123
+ }}
124
+ />
125
+ </SLDSGlobalHeader>
126
+ </SLDSIconSettings>
127
+ ).call(this);
128
+
129
+ const actionButton = this.wrapper.find(
130
+ 'button.slds-global-actions__favorites-action'
131
+ );
132
+
133
+ actionButton.simulate('click');
134
+ expect(typeof args.event).to.eql('object');
135
+ expect(typeof args.data).to.eql('object');
136
+ expect(typeof args.data.actionSelected).to.eql('boolean');
137
+
138
+ args = {};
139
+ actionButton.simulate('keydown', { keyCode: 13 });
140
+ expect(typeof args.event).to.eql('object');
141
+ expect(typeof args.data).to.eql('object');
142
+ expect(typeof args.data.actionSelected).to.eql('boolean');
143
+
144
+ unmountComponent.call(this);
145
+ });
146
+ });
147
+
148
+ describe('SLDSGlobalHeaderNotifications', () => {
149
+ it('handles notificationCount correctly when no value provided', function () {
150
+ mountComponent(
151
+ <SLDSIconSettings iconPath="/assets/icons">
152
+ <SLDSGlobalHeader>
153
+ <SLDSGlobalHeaderNotifications />
154
+ </SLDSGlobalHeader>
155
+ </SLDSIconSettings>
156
+ ).call(this);
157
+
158
+ expect(this.wrapper.find('.slds-notification-badge').text()).to.eql('');
159
+
160
+ unmountComponent.call(this);
161
+ });
162
+
163
+ it('handles notificationCount correctly when a value is provided', function () {
164
+ mountComponent(
165
+ <SLDSIconSettings iconPath="/assets/icons">
166
+ <SLDSGlobalHeader>
167
+ <SLDSGlobalHeaderNotifications notificationCount={5} />
168
+ </SLDSGlobalHeader>
169
+ </SLDSIconSettings>
170
+ ).call(this);
171
+
172
+ expect(this.wrapper.find('.slds-notification-badge').text()).to.eql('5');
173
+
174
+ unmountComponent.call(this);
175
+ });
176
+ });
177
+ });
@@ -0,0 +1,464 @@
1
+ import React from 'react';
2
+ import { mount } from 'enzyme';
3
+ import chai, { expect } from 'chai';
4
+ import chaiEnzyme from 'chai-enzyme';
5
+
6
+ // `this.wrapper` and `this.dom` is set in the helpers file
7
+ import {
8
+ mountComponent,
9
+ unmountComponent,
10
+ } from '../../../tests/enzyme-helpers';
11
+
12
+ // sample props and children
13
+ import {
14
+ dropdownCollection,
15
+ propSets,
16
+ } from '../../../utilities/sample-data/global-navigation-bar';
17
+
18
+ import IconSettings from '../../icon-settings';
19
+ import GlobalNavigationBar from '../../global-navigation-bar';
20
+ import GlobalNavigationBarRegion from '../../global-navigation-bar/region';
21
+ import GlobalNavigationBarDropdown from '../../global-navigation-bar/dropdown';
22
+ import GlobalNavigationBarDropdownTrigger from '../../global-navigation-bar/dropdown-trigger';
23
+ import GlobalNavigationBarLink from '../../global-navigation-bar/link';
24
+ import GlobalNavigationBarLabel from '../../global-navigation-bar/label';
25
+ import GlobalNavigationBarButton from '../../global-navigation-bar/button';
26
+
27
+ chai.use(chaiEnzyme());
28
+
29
+ const COMPONENT_CSS_CLASSES = {
30
+ base: 'slds-context-bar',
31
+ themePrefix: 'slds-context-bar_theme-',
32
+ };
33
+
34
+ const REGION_CSS_CLASSES = {
35
+ primary: 'slds-context-bar__primary',
36
+ secondary: 'slds-context-bar__secondary',
37
+ tertiary: 'slds-context-bar__tertiary',
38
+ appName: 'slds-context-bar__app-name',
39
+ };
40
+
41
+ describe('Global Navigation Bar: ', () => {
42
+ // Base defaults
43
+ // no required props
44
+
45
+ /*
46
+ Tests
47
+ */
48
+ describe('Default Structure', () => {
49
+ beforeEach(
50
+ mountComponent(
51
+ <IconSettings iconPath="/assets/icons">
52
+ <GlobalNavigationBar>
53
+ <GlobalNavigationBarRegion region="primary" />
54
+ </GlobalNavigationBar>
55
+ </IconSettings>
56
+ )
57
+ );
58
+
59
+ afterEach(unmountComponent);
60
+
61
+ it('has wrapping div and one primary region', function () {
62
+ expect(
63
+ this.wrapper.find(`.${COMPONENT_CSS_CLASSES.base}`)
64
+ ).to.be.present();
65
+ expect(
66
+ this.wrapper.find(`.${REGION_CSS_CLASSES.primary}`)
67
+ ).to.be.present();
68
+ });
69
+
70
+ it('Primary region DOES NOT have divider on right', function () {
71
+ const primary = this.wrapper.find(`.${REGION_CSS_CLASSES.primary}`);
72
+ expect(primary).to.not.have.className(
73
+ 'slds-context-bar__item_divider-right'
74
+ );
75
+ });
76
+ });
77
+
78
+ describe('Optional Properties', () => {
79
+ const customCloudProps = propSets.customCloud.props;
80
+ const customThemeProps = propSets.lightTheme.props;
81
+
82
+ beforeEach(
83
+ mountComponent(
84
+ <IconSettings iconPath="/assets/icons">
85
+ <GlobalNavigationBar {...customCloudProps} {...customThemeProps} />
86
+ </IconSettings>
87
+ )
88
+ );
89
+
90
+ afterEach(unmountComponent);
91
+
92
+ it('has custom cloud and theme CSS', function () {
93
+ const component = this.wrapper.find(`.${COMPONENT_CSS_CLASSES.base}`);
94
+ expect(component).to.have.className(
95
+ `${COMPONENT_CSS_CLASSES.themePrefix}${customCloudProps.cloud}`
96
+ );
97
+ expect(component).to.have.className(
98
+ `${COMPONENT_CSS_CLASSES.themePrefix}${customThemeProps.theme}`
99
+ );
100
+ });
101
+ });
102
+
103
+ describe('Optional Region Structure', () => {
104
+ const { props } = propSets.base;
105
+
106
+ const buttonClicked = () => {};
107
+ const linkClicked = () => {};
108
+ const dropdownItemClicked = () => {};
109
+
110
+ beforeEach(
111
+ mountComponent(
112
+ <IconSettings iconPath="/assets/icons">
113
+ <GlobalNavigationBar {...props}>
114
+ <GlobalNavigationBarRegion region="primary" />
115
+ <GlobalNavigationBarRegion
116
+ region="secondary"
117
+ navigation
118
+ dividerPosition="right"
119
+ >
120
+ <GlobalNavigationBarLink
121
+ label="Home"
122
+ id="home-link"
123
+ onClick={linkClicked('Home link clicked')}
124
+ />
125
+ <GlobalNavigationBarDropdown
126
+ assistiveText={{ icon: 'Open Menu' }}
127
+ id="primaryDropdown"
128
+ label="Global Navigation Menu Item 1"
129
+ onSelect={dropdownItemClicked('Dropdown Menu Item clicked')}
130
+ options={dropdownCollection}
131
+ />
132
+ <GlobalNavigationBarLink
133
+ active
134
+ id="menu-item-2"
135
+ label="Global Navigation Menu Item 2"
136
+ onClick={linkClicked('Link clicked')}
137
+ />
138
+ <GlobalNavigationBarDropdown
139
+ active
140
+ assistiveText={{ icon: 'Open Menu' }}
141
+ id="primaryDropdownActive"
142
+ label="Global Navigation Menu Item 3"
143
+ onSelect={dropdownItemClicked('Dropdown Menu Item clicked')}
144
+ options={dropdownCollection}
145
+ />
146
+ </GlobalNavigationBarRegion>
147
+ <GlobalNavigationBarRegion region="tertiary">
148
+ <GlobalNavigationBarLink
149
+ label="Actions"
150
+ onClick={linkClicked('Link clicked')}
151
+ />
152
+ <GlobalNavigationBarButton
153
+ active
154
+ label="Button"
155
+ id="global-nav__button"
156
+ onClick={buttonClicked('Button clicked')}
157
+ />
158
+ <GlobalNavigationBarLabel
159
+ dividerPosition="left"
160
+ label="Vandelay Enterprises"
161
+ />
162
+ </GlobalNavigationBarRegion>
163
+ </GlobalNavigationBar>
164
+ </IconSettings>
165
+ )
166
+ );
167
+
168
+ afterEach(unmountComponent);
169
+
170
+ it('has 1 primary, 1 secondary, and 1 tertiary region', function () {
171
+ expect(
172
+ this.wrapper.find(`.${REGION_CSS_CLASSES.primary}`)
173
+ ).to.be.present();
174
+ expect(
175
+ this.wrapper.find(`.${REGION_CSS_CLASSES.secondary}`)
176
+ ).to.be.present();
177
+ expect(
178
+ this.wrapper.find(`.${REGION_CSS_CLASSES.tertiary}`)
179
+ ).to.be.present();
180
+ });
181
+
182
+ it('Secondary region application is a nav HTML element and has divider on right side', function () {
183
+ const nav = this.wrapper.find(`.${REGION_CSS_CLASSES.secondary}`);
184
+ expect(nav.type()).to.equal('nav');
185
+ expect(nav).to.have.className('slds-context-bar__item_divider-right');
186
+ });
187
+
188
+ it('displays active items as active', function () {
189
+ const activeItems = this.wrapper.find('.slds-is-active');
190
+ expect(activeItems).to.have.length(3);
191
+ });
192
+ });
193
+
194
+ describe('Secondary Region', () => {
195
+ beforeEach(
196
+ mountComponent(
197
+ <IconSettings iconPath="/assets/icons">
198
+ <GlobalNavigationBarRegion region="secondary" />
199
+ </IconSettings>
200
+ )
201
+ );
202
+
203
+ afterEach(unmountComponent);
204
+
205
+ it('Secondary region application is div and not a nav', function () {
206
+ const nav = this.wrapper.find(`.${REGION_CSS_CLASSES.secondary}`);
207
+ expect(nav.type()).to.equal('div');
208
+ });
209
+ });
210
+
211
+ describe('GlobalNavigationDropdown child component', () => {
212
+ let dropdown;
213
+ let eventTest;
214
+
215
+ const eventHandler = (option, moreData) => {
216
+ eventTest = { option, moreData };
217
+ };
218
+
219
+ beforeEach(function () {
220
+ mountComponent(
221
+ <GlobalNavigationBarDropdown
222
+ dividerPosition="left"
223
+ label="Test"
224
+ onSelect={eventHandler}
225
+ options={dropdownCollection}
226
+ />
227
+ ).call(this);
228
+
229
+ dropdown = this.wrapper.find('.slds-context-bar__dropdown-trigger');
230
+ eventTest = null;
231
+ });
232
+
233
+ afterEach(unmountComponent);
234
+
235
+ it('calls onSelect handler properly', function () {
236
+ dropdown.find('button.slds-context-bar__button').simulate('click');
237
+ this.wrapper
238
+ .find('.slds-dropdown ul.dropdown__list')
239
+ .childAt(0)
240
+ .find('a')
241
+ .simulate('click');
242
+ expect(typeof eventTest.option).to.eql('object');
243
+ expect(typeof eventTest.moreData).to.eql('object');
244
+ });
245
+
246
+ it('renders divider as expected', function () {
247
+ expect(dropdown.hasClass('slds-context-bar__item_divider-left')).to.eql(
248
+ true
249
+ );
250
+ });
251
+ });
252
+
253
+ describe('GlobalNavigationDropdownTrigger child component', () => {
254
+ let dropdownTrigger;
255
+ let eventTest;
256
+
257
+ const eventHandler = (event, data) => {
258
+ eventTest = { event, data };
259
+ };
260
+
261
+ beforeEach(function () {
262
+ mountComponent(
263
+ <GlobalNavigationBarDropdownTrigger
264
+ dividerPosition="left"
265
+ label="Test"
266
+ onBlur={eventHandler}
267
+ onClick={eventHandler}
268
+ onFocus={eventHandler}
269
+ onKeyDown={eventHandler}
270
+ onMouseDown={eventHandler}
271
+ onMouseEnter={eventHandler}
272
+ onMouseLeave={eventHandler}
273
+ />
274
+ ).call(this);
275
+
276
+ dropdownTrigger = this.wrapper.find(
277
+ '.slds-context-bar__dropdown-trigger'
278
+ );
279
+ eventTest = null;
280
+ });
281
+
282
+ afterEach(unmountComponent);
283
+
284
+ it('has appropriate attributes', function () {
285
+ expect(dropdownTrigger.text()).to.equal('TestOpen menu item submenu');
286
+ });
287
+
288
+ it('calls onClick handler properly', function () {
289
+ dropdownTrigger.simulate('click');
290
+ expect(typeof eventTest.event).to.eql('object');
291
+ });
292
+
293
+ it('calls onBlur handler properly', function () {
294
+ dropdownTrigger.simulate('blur');
295
+ expect(typeof eventTest.event).to.eql('object');
296
+ });
297
+
298
+ it('calls onFocus handler properly', function () {
299
+ dropdownTrigger.simulate('focus');
300
+ expect(typeof eventTest.event).to.eql('object');
301
+ });
302
+
303
+ it('calls onKeyDown handler properly', function () {
304
+ dropdownTrigger.simulate('keydown', { keyCode: 13 });
305
+ expect(typeof eventTest.event).to.eql('object');
306
+ });
307
+
308
+ it('calls onMouseDown handler properly', function () {
309
+ dropdownTrigger.simulate('mousedown');
310
+ expect(typeof eventTest.event).to.eql('object');
311
+ });
312
+
313
+ it('calls onMouseEnter handler properly', function () {
314
+ dropdownTrigger.simulate('mouseenter');
315
+ expect(typeof eventTest.event).to.eql('object');
316
+ });
317
+
318
+ it('calls onMouseLeave handler properly', function () {
319
+ dropdownTrigger.simulate('mouseleave');
320
+ expect(typeof eventTest.event).to.eql('object');
321
+ });
322
+
323
+ it('renders divider as expected', function () {
324
+ expect(
325
+ dropdownTrigger.hasClass('slds-context-bar__item_divider-left')
326
+ ).to.eql(true);
327
+ });
328
+ });
329
+
330
+ describe('GlobalNavigationLink child component', () => {
331
+ let aTag;
332
+ let eventTest;
333
+ let link;
334
+
335
+ const eventHandler = (event, data) => {
336
+ eventTest = { event, data };
337
+ };
338
+
339
+ beforeEach(function () {
340
+ mountComponent(
341
+ <GlobalNavigationBarLink
342
+ dividerPosition="left"
343
+ href="http://google.com"
344
+ label="Home"
345
+ id="home-link"
346
+ onBlur={eventHandler}
347
+ onClick={eventHandler}
348
+ onFocus={eventHandler}
349
+ onKeyDown={eventHandler}
350
+ onKeyPress={eventHandler}
351
+ onKeyUp={eventHandler}
352
+ onMouseEnter={eventHandler}
353
+ onMouseLeave={eventHandler}
354
+ />
355
+ ).call(this);
356
+
357
+ link = this.wrapper.find('li#home-link');
358
+ aTag = link.find('a');
359
+ eventTest = null;
360
+ });
361
+
362
+ afterEach(unmountComponent);
363
+
364
+ it('has appropriate attributes', function () {
365
+ expect(link.text()).to.equal('Home');
366
+ });
367
+
368
+ it('calls onClick handler properly', function () {
369
+ aTag.simulate('click');
370
+ expect(typeof eventTest.event).to.eql('object');
371
+ expect(typeof eventTest.data.href).to.eql('string');
372
+ });
373
+
374
+ it('calls onBlur handler properly', function () {
375
+ aTag.simulate('blur');
376
+ expect(typeof eventTest.event).to.eql('object');
377
+ });
378
+
379
+ it('calls onFocus handler properly', function () {
380
+ aTag.simulate('focus');
381
+ expect(typeof eventTest.event).to.eql('object');
382
+ });
383
+
384
+ it('calls onKeyDown handler properly', function () {
385
+ aTag.simulate('keydown', { keyCode: 13 });
386
+ expect(typeof eventTest.event).to.eql('object');
387
+ });
388
+
389
+ it('calls onKeyPress handler properly', function () {
390
+ aTag.simulate('keypress', { keyCode: 13 });
391
+ expect(typeof eventTest.event).to.eql('object');
392
+ });
393
+
394
+ it('calls onKeyUp handler properly', function () {
395
+ aTag.simulate('keyup', { keyCode: 13 });
396
+ expect(typeof eventTest.event).to.eql('object');
397
+ });
398
+
399
+ it('calls onMouseEnter handler properly', function () {
400
+ aTag.simulate('mouseenter');
401
+ expect(typeof eventTest.event).to.eql('object');
402
+ });
403
+
404
+ it('calls onMouseLeave handler properly', function () {
405
+ aTag.simulate('mouseleave');
406
+ expect(typeof eventTest.event).to.eql('object');
407
+ });
408
+
409
+ it('renders href if passed', () => {
410
+ expect(link.find('a')).to.have.attr('href', 'http://google.com');
411
+ });
412
+
413
+ it('renders divider as expected', function () {
414
+ expect(link.hasClass('slds-context-bar__item_divider-left')).to.eql(true);
415
+ });
416
+ });
417
+
418
+ describe('GlobalNavigationButton child component', () => {
419
+ it('GlobalNavigationBarButton has attributes and onClick runs callback', function () {
420
+ const buttonClicked = sinon.spy();
421
+ const instance = (
422
+ <GlobalNavigationBarButton
423
+ label="Button"
424
+ id="global-nav__button"
425
+ onClick={buttonClicked('Button clicked')}
426
+ />
427
+ );
428
+ this.wrapper = mount(instance, {
429
+ attachTo: document.body.appendChild(document.createElement('div')),
430
+ });
431
+ const link = this.wrapper.find('button#global-nav__button');
432
+ expect(link.text()).to.equal('Button');
433
+ link.simulate('click');
434
+ expect(buttonClicked.calledOnce).to.be.true;
435
+
436
+ this.wrapper.unmount();
437
+ });
438
+ });
439
+
440
+ describe('GlobalNavigationLabel child component', () => {
441
+ it('GlobalNavigationBarLabel has attributes and renders dividerPosition correctly', function () {
442
+ const instance = (
443
+ <GlobalNavigationBarLabel
444
+ dividerPosition="right"
445
+ label="Text"
446
+ id="test-text"
447
+ />
448
+ );
449
+ this.wrapper = mount(instance, {
450
+ attachTo: document.body.appendChild(document.createElement('div')),
451
+ });
452
+ const item = this.wrapper.find('span#test-text');
453
+
454
+ expect(
455
+ this.wrapper
456
+ .find('span.slds-context-bar__label-action')
457
+ .hasClass('slds-context-bar__item_divider-right')
458
+ ).to.eql(true);
459
+ expect(item.text()).to.equal('Text');
460
+
461
+ this.wrapper.unmount();
462
+ });
463
+ });
464
+ });