@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,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import chai from 'chai';
|
|
4
|
+
|
|
5
|
+
import Spinner from '../../spinner';
|
|
6
|
+
|
|
7
|
+
chai.should();
|
|
8
|
+
|
|
9
|
+
describe('Spinner: ', () => {
|
|
10
|
+
// Setup and takedown
|
|
11
|
+
const renderSpinner = (instance) =>
|
|
12
|
+
function () {
|
|
13
|
+
this.dom = document.createElement('div');
|
|
14
|
+
document.body.appendChild(this.dom);
|
|
15
|
+
// eslint-disable-next-line react/no-render-return-value
|
|
16
|
+
this.component = ReactDOM.render(instance, this.dom); // deepscan-disable-line REACT_ASYNC_RENDER_RETURN_VALUE
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function removeSpinner() {
|
|
20
|
+
ReactDOM.unmountComponentAtNode(this.dom);
|
|
21
|
+
document.body.removeChild(this.dom);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const getSpinner = (dom) => dom.querySelector('.slds-spinner');
|
|
25
|
+
|
|
26
|
+
// Tests
|
|
27
|
+
describe('Default spinner renders properly', () => {
|
|
28
|
+
before(renderSpinner(<Spinner />));
|
|
29
|
+
|
|
30
|
+
after(removeSpinner);
|
|
31
|
+
|
|
32
|
+
it('Spinner exists', function () {
|
|
33
|
+
const spinner = getSpinner(this.dom);
|
|
34
|
+
spinner.should.not.be.undefined;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('renders default classes when no props passed in', function () {
|
|
38
|
+
const spinner = getSpinner(this.dom);
|
|
39
|
+
spinner.className.should.equal('slds-spinner slds-spinner_medium');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('Props render proper css classes', () => {
|
|
44
|
+
beforeEach(
|
|
45
|
+
renderSpinner(<Spinner size="small" variant="brand" isDelayed />)
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
afterEach(removeSpinner);
|
|
49
|
+
|
|
50
|
+
it('renders correct classes when props passed in', function () {
|
|
51
|
+
const spinner = getSpinner(this.dom);
|
|
52
|
+
spinner.className.should.include(
|
|
53
|
+
'slds-spinner_brand slds-spinner_delayed slds-spinner_small'
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import chai, { expect } from 'chai';
|
|
3
|
+
import chaiEnzyme from 'chai-enzyme';
|
|
4
|
+
import { mount } from 'enzyme';
|
|
5
|
+
import sinon from 'sinon';
|
|
6
|
+
|
|
7
|
+
import IconSettings from '../../../components/icon-settings';
|
|
8
|
+
import SplitViewListbox from '../../../components/split-view/listbox';
|
|
9
|
+
|
|
10
|
+
chai.use(chaiEnzyme());
|
|
11
|
+
|
|
12
|
+
const listOptions = [
|
|
13
|
+
{
|
|
14
|
+
id: 'option1',
|
|
15
|
+
label: 'Riley Shultz',
|
|
16
|
+
topRightText: '99',
|
|
17
|
+
bottomLeftText: 'Biotech, Inc.',
|
|
18
|
+
bottomRightText: 'Nurturing',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 'option2',
|
|
22
|
+
label: 'Jason A. - VP of Sales',
|
|
23
|
+
topRightText: '92',
|
|
24
|
+
bottomLeftText: 'Case Management Solutions',
|
|
25
|
+
bottomRightText: 'Contacted',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'option3',
|
|
29
|
+
label: 'Josh Smith',
|
|
30
|
+
topRightText: '90',
|
|
31
|
+
bottomLeftText: 'Acme, Inc.',
|
|
32
|
+
bottomRightText: 'Contacted',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'option4',
|
|
36
|
+
label: 'Bobby Tree',
|
|
37
|
+
topRightText: '89',
|
|
38
|
+
bottomLeftText: 'Salesforce, Inc.',
|
|
39
|
+
bottomRightText: 'Closing',
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
describe('SLDSSplitView - Listbox', () => {
|
|
44
|
+
let component;
|
|
45
|
+
|
|
46
|
+
const WrappedComponent = (props) => (
|
|
47
|
+
<IconSettings iconPath="/assets/icons">
|
|
48
|
+
<SplitViewListbox {...props} />
|
|
49
|
+
</IconSettings>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const mountComponent = (props) => mount(<WrappedComponent {...props} />);
|
|
53
|
+
|
|
54
|
+
const expectItemFocused = (value) => {
|
|
55
|
+
const anchors = component.find('li > a');
|
|
56
|
+
|
|
57
|
+
listOptions.forEach((item, index) => {
|
|
58
|
+
expect(anchors.get(index).props.tabIndex).to.equal(
|
|
59
|
+
index === value ? 0 : -1
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const expectItemSelected = (value) => {
|
|
65
|
+
const itemIndex = Array.isArray(value) ? value : [value];
|
|
66
|
+
|
|
67
|
+
const anchors = component.find('li > a');
|
|
68
|
+
|
|
69
|
+
listOptions.forEach((item, index) => {
|
|
70
|
+
itemIndex.includes(index)
|
|
71
|
+
? expect(anchors.at(index).prop('aria-selected')).to.be.true
|
|
72
|
+
: expect(anchors.at(index).prop('aria-selected')).to.be.false;
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
describe('When the component is mounted', () => {
|
|
77
|
+
it('should focus the first selected item', () => {
|
|
78
|
+
component = mountComponent({
|
|
79
|
+
options: listOptions,
|
|
80
|
+
selection: [listOptions[1]],
|
|
81
|
+
events: {
|
|
82
|
+
onSelect: sinon.spy(),
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
expectItemFocused(1);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should focus the first item when there is no selection', () => {
|
|
90
|
+
component = mountComponent({
|
|
91
|
+
options: listOptions,
|
|
92
|
+
events: {
|
|
93
|
+
onSelect: sinon.spy(),
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
expectItemFocused(0);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe('When a list item is selected', () => {
|
|
102
|
+
describe('and single select only', () => {
|
|
103
|
+
it('should focus the item that is clicked', () => {
|
|
104
|
+
component = mountComponent({
|
|
105
|
+
options: listOptions,
|
|
106
|
+
events: {
|
|
107
|
+
onSelect: () => {},
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
component.find('li > a').at(2).simulate('click');
|
|
112
|
+
|
|
113
|
+
expectItemFocused(2);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should select the item that is clicked', () => {
|
|
117
|
+
component = mountComponent({
|
|
118
|
+
options: listOptions,
|
|
119
|
+
events: {
|
|
120
|
+
onSelect: (event, { selectedItems }) => {
|
|
121
|
+
component.setProps({ selection: selectedItems });
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
component.find('li > a').at(2).simulate('click');
|
|
127
|
+
|
|
128
|
+
expectItemSelected(2);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
describe('and using the keyboard', () => {
|
|
132
|
+
beforeEach(() => {
|
|
133
|
+
component = mountComponent({
|
|
134
|
+
options: listOptions,
|
|
135
|
+
selection: [listOptions[1]],
|
|
136
|
+
events: {
|
|
137
|
+
onSelect: (event, { selectedItems }) => {
|
|
138
|
+
component.setProps({ selection: selectedItems });
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
describe('and "ctrl a" keyed', () => {
|
|
145
|
+
it('should not select all list items', () => {
|
|
146
|
+
component
|
|
147
|
+
.find('ul')
|
|
148
|
+
.simulate('keyDown', { key: 'a', ctrlKey: true });
|
|
149
|
+
|
|
150
|
+
expectItemSelected([1]);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('and arrow key up it should focus the previous item', () => {
|
|
155
|
+
component.find('ul').simulate('keyDown', { key: 'ArrowUp' });
|
|
156
|
+
expectItemFocused(0);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('and arrow key down it should focus the next item', () => {
|
|
160
|
+
component.find('ul').simulate('keyDown', { key: 'ArrowDown' });
|
|
161
|
+
expectItemFocused(2);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('and arrow key up followed by click/enter should select the previous item', () => {
|
|
165
|
+
component.find('ul').simulate('keyDown', { key: 'ArrowUp' });
|
|
166
|
+
component.find('ul li a').at(0).simulate('click');
|
|
167
|
+
expectItemSelected(0);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('and arrow key down followed by click/enter should select the next item', () => {
|
|
171
|
+
component.find('ul').simulate('keyDown', { key: 'ArrowDown' });
|
|
172
|
+
component.find('ul li a').at(2).simulate('click');
|
|
173
|
+
expectItemSelected(2);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
describe('and multiple select enabled', () => {
|
|
179
|
+
beforeEach(() => {
|
|
180
|
+
component = mountComponent({
|
|
181
|
+
multiple: true,
|
|
182
|
+
options: listOptions,
|
|
183
|
+
events: {
|
|
184
|
+
onSelect: (event, { selectedItems }) => {
|
|
185
|
+
component.setProps({ selection: selectedItems });
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('should select multiple items when clicked and the metaKey is pressed', () => {
|
|
192
|
+
const anchors = component.find('li > a');
|
|
193
|
+
|
|
194
|
+
anchors.at(2).simulate('click');
|
|
195
|
+
anchors.at(3).simulate('click', { metaKey: true });
|
|
196
|
+
|
|
197
|
+
expectItemSelected([2, 3]);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it('should select multiple items when clicked and the shiftKey is pressed', () => {
|
|
201
|
+
const anchors = component.find('li > a');
|
|
202
|
+
|
|
203
|
+
anchors.at(1).simulate('click');
|
|
204
|
+
anchors.at(3).simulate('click', { shiftKey: true });
|
|
205
|
+
|
|
206
|
+
expectItemSelected([1, 2, 3]);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
describe('and "ctrl a" keyed', () => {
|
|
210
|
+
it('should select all list items', () => {
|
|
211
|
+
component.find('ul').simulate('keyDown', { key: 'a', ctrlKey: true });
|
|
212
|
+
|
|
213
|
+
expectItemSelected([0, 1, 2, 3]);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it('should de-select all list items when all the list items are already selected', () => {
|
|
217
|
+
component.setProps({ selection: listOptions });
|
|
218
|
+
component.find('ul').simulate('keyDown', { key: 'a', ctrlKey: true });
|
|
219
|
+
|
|
220
|
+
expectItemSelected([]);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
});
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import chai, { expect } from 'chai';
|
|
3
|
+
import chaiEnzyme from 'chai-enzyme';
|
|
4
|
+
import { mount } from 'enzyme';
|
|
5
|
+
import sinon from 'sinon';
|
|
6
|
+
|
|
7
|
+
import IconSettings from '../../../components/icon-settings';
|
|
8
|
+
import SplitViewListbox, {
|
|
9
|
+
SORT_OPTIONS,
|
|
10
|
+
} from '../../../components/split-view/listbox';
|
|
11
|
+
|
|
12
|
+
chai.use(chaiEnzyme());
|
|
13
|
+
|
|
14
|
+
const listOptions = [
|
|
15
|
+
{
|
|
16
|
+
id: 'option1',
|
|
17
|
+
label: 'Riley Shultz',
|
|
18
|
+
topRightText: '99',
|
|
19
|
+
bottomLeftText: 'Biotech, Inc.',
|
|
20
|
+
bottomRightText: 'Nurturing',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'option2',
|
|
24
|
+
label: 'Jason A. - VP of Sales',
|
|
25
|
+
topRightText: '92',
|
|
26
|
+
bottomLeftText: 'Case Management Solutions',
|
|
27
|
+
bottomRightText: 'Contacted',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'option3',
|
|
31
|
+
label: 'Josh Smith',
|
|
32
|
+
topRightText: '90',
|
|
33
|
+
bottomLeftText: 'Acme, Inc.',
|
|
34
|
+
bottomRightText: 'Contacted',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'option4',
|
|
38
|
+
label: 'Bobby Tree',
|
|
39
|
+
topRightText: '89',
|
|
40
|
+
bottomLeftText: 'Salesforce, Inc.',
|
|
41
|
+
bottomRightText: 'Closing',
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
describe('SLDSSplitView - Listbox header', () => {
|
|
46
|
+
let component;
|
|
47
|
+
|
|
48
|
+
const WrappedComponent = (props) => (
|
|
49
|
+
<IconSettings iconPath="/assets/icons">
|
|
50
|
+
<SplitViewListbox {...props} />
|
|
51
|
+
</IconSettings>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const mountComponent = (props) => mount(<WrappedComponent {...props} />);
|
|
55
|
+
|
|
56
|
+
const props = {
|
|
57
|
+
options: listOptions,
|
|
58
|
+
labels: {
|
|
59
|
+
header: 'test header',
|
|
60
|
+
},
|
|
61
|
+
assistiveText: {
|
|
62
|
+
sort: {
|
|
63
|
+
sortedBy: 'test sort by',
|
|
64
|
+
descending: 'test descending',
|
|
65
|
+
ascending: 'test ascending',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
sortDirection: SORT_OPTIONS.DOWN,
|
|
69
|
+
events: {
|
|
70
|
+
onSort: sinon.spy(),
|
|
71
|
+
onSelect: (event, { selectedItems }) => {
|
|
72
|
+
component.setProps({ selection: selectedItems });
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
beforeEach(() => {
|
|
78
|
+
component = mountComponent(props);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('should have a header', () => {
|
|
82
|
+
expect(component.find('.slds-split-view__list-header')).to.have.length(1);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should not have a header when no label specified', () => {
|
|
86
|
+
component.setProps({ labels: {} });
|
|
87
|
+
expect(component.find('.slds-split-view__list-header')).to.have.length(0);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should have test label', () => {
|
|
91
|
+
expect(
|
|
92
|
+
component.find('.slds-split-view__list-header > span > span').at(1).text()
|
|
93
|
+
).to.equal('test header');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should have sort by assistive text', () => {
|
|
97
|
+
expect(
|
|
98
|
+
component.find('.slds-split-view__list-header > span > span').at(0).text()
|
|
99
|
+
).to.equal('test sort by: ');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('sort', () => {
|
|
103
|
+
describe('direction', () => {
|
|
104
|
+
it('should have a sort direction down icon', () => {
|
|
105
|
+
expect(
|
|
106
|
+
component.find('.slds-split-view__list-header svg > use').prop('href')
|
|
107
|
+
).to.have.string('arrowdown');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should have sort descending assistive text', () => {
|
|
111
|
+
expect(
|
|
112
|
+
component
|
|
113
|
+
.find('.slds-split-view__list-header > span > span')
|
|
114
|
+
.at(2)
|
|
115
|
+
.text()
|
|
116
|
+
).to.equal('- test descending');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('should have a sort direction up icon', () => {
|
|
120
|
+
component.setProps({ sortDirection: SORT_OPTIONS.UP });
|
|
121
|
+
|
|
122
|
+
expect(
|
|
123
|
+
component.find('.slds-split-view__list-header svg > use').prop('href')
|
|
124
|
+
).to.have.string('arrowup');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('should have sort ascending assistive text', () => {
|
|
128
|
+
component.setProps({ sortDirection: SORT_OPTIONS.UP });
|
|
129
|
+
|
|
130
|
+
expect(
|
|
131
|
+
component
|
|
132
|
+
.find('.slds-split-view__list-header > span > span')
|
|
133
|
+
.at(2)
|
|
134
|
+
.text()
|
|
135
|
+
).to.equal('- test ascending');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('should not have a sort direction when no direction specified', () => {
|
|
139
|
+
component.setProps({ sortDirection: undefined });
|
|
140
|
+
expect(
|
|
141
|
+
component.find('.slds-split-view__list-header svg')
|
|
142
|
+
).to.have.length(0);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('should call onSort when the header is clicked', () => {
|
|
146
|
+
component.find('a.slds-split-view__list-header').simulate('click');
|
|
147
|
+
expect(props.events.onSort.called).to.be.true;
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('should not be clickable when onSort not specified', () => {
|
|
151
|
+
component.setProps({ events: { onSelect: sinon.spy() } });
|
|
152
|
+
expect(component.find('.slds-split-view__list-header a')).to.be.length(
|
|
153
|
+
0
|
|
154
|
+
);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import chai, { expect } from 'chai';
|
|
3
|
+
import chaiEnzyme from 'chai-enzyme';
|
|
4
|
+
import { mount } from 'enzyme';
|
|
5
|
+
import sinon from 'sinon';
|
|
6
|
+
|
|
7
|
+
import IconSettings from '../../../components/icon-settings';
|
|
8
|
+
import SplitViewListbox, {
|
|
9
|
+
SORT_OPTIONS,
|
|
10
|
+
} from '../../../components/split-view/listbox';
|
|
11
|
+
|
|
12
|
+
chai.use(chaiEnzyme());
|
|
13
|
+
|
|
14
|
+
const listOptions = [
|
|
15
|
+
{
|
|
16
|
+
id: 'option1',
|
|
17
|
+
label: 'Riley Shultz',
|
|
18
|
+
topRightText: '99',
|
|
19
|
+
bottomLeftText: 'Biotech, Inc.',
|
|
20
|
+
bottomRightText: 'Nurturing',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'option2',
|
|
24
|
+
label: 'Jason A. - VP of Sales',
|
|
25
|
+
topRightText: '92',
|
|
26
|
+
bottomLeftText: 'Case Management Solutions',
|
|
27
|
+
bottomRightText: 'Contacted',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'option3',
|
|
31
|
+
label: 'Josh Smith',
|
|
32
|
+
topRightText: '90',
|
|
33
|
+
bottomLeftText: 'Acme, Inc.',
|
|
34
|
+
bottomRightText: 'Contacted',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'option4',
|
|
38
|
+
label: 'Bobby Tree',
|
|
39
|
+
topRightText: '89',
|
|
40
|
+
bottomLeftText: 'Salesforce, Inc.',
|
|
41
|
+
bottomRightText: 'Closing',
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
describe('SLDSSplitView - Listbox header', () => {
|
|
46
|
+
let component;
|
|
47
|
+
|
|
48
|
+
const WrappedComponent = (props) => (
|
|
49
|
+
<IconSettings iconPath="/assets/icons">
|
|
50
|
+
<SplitViewListbox {...props} />
|
|
51
|
+
</IconSettings>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const mountComponent = (props) => mount(<WrappedComponent {...props} />);
|
|
55
|
+
|
|
56
|
+
const props = {
|
|
57
|
+
options: listOptions,
|
|
58
|
+
unread: [listOptions[1], listOptions[3]],
|
|
59
|
+
labels: {
|
|
60
|
+
header: 'test header',
|
|
61
|
+
},
|
|
62
|
+
assistiveText: {
|
|
63
|
+
sort: {
|
|
64
|
+
sortedBy: 'test sort by',
|
|
65
|
+
descending: 'test descending',
|
|
66
|
+
ascending: 'test ascending',
|
|
67
|
+
},
|
|
68
|
+
unreadItem: 'test unread',
|
|
69
|
+
},
|
|
70
|
+
sortDirection: SORT_OPTIONS.DOWN,
|
|
71
|
+
events: {
|
|
72
|
+
onSort: sinon.spy(),
|
|
73
|
+
onSelect: (event, { selectedItems }) => {
|
|
74
|
+
component.setProps({ selection: selectedItems });
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
component = mountComponent(props);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should have unread', () => {
|
|
84
|
+
expect(component.find('li').at(0).prop('className')).to.not.contain(
|
|
85
|
+
'slds-is-unread'
|
|
86
|
+
);
|
|
87
|
+
expect(component.find('li').at(1).prop('className')).to.contain(
|
|
88
|
+
'slds-is-unread'
|
|
89
|
+
);
|
|
90
|
+
expect(component.find('li').at(2).prop('className')).to.not.contain(
|
|
91
|
+
'slds-is-unread'
|
|
92
|
+
);
|
|
93
|
+
expect(component.find('li').at(3).prop('className')).to.contain(
|
|
94
|
+
'slds-is-unread'
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
expect(component.find('.slds-indicator_unread')).to.have.length(2);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should have unread assistive text', () => {
|
|
101
|
+
expect(
|
|
102
|
+
component.find('.slds-indicator_unread').at(0).prop('title')
|
|
103
|
+
).to.equal('test unread');
|
|
104
|
+
expect(
|
|
105
|
+
component.find('.slds-indicator_unread').at(1).prop('title')
|
|
106
|
+
).to.equal('test unread');
|
|
107
|
+
expect(
|
|
108
|
+
component.find('.slds-indicator_unread').at(0).prop('aria-label')
|
|
109
|
+
).to.equal('test unread');
|
|
110
|
+
expect(
|
|
111
|
+
component.find('.slds-indicator_unread').at(1).prop('aria-label')
|
|
112
|
+
).to.equal('test unread');
|
|
113
|
+
});
|
|
114
|
+
});
|