@zohodesk/components 1.6.32 → 1.6.34
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/CHANGELOG.md +9 -0
- package/es/Accordion/__tests__/Accordion.spec.js +117 -3
- package/es/Accordion/__tests__/AccordionItem.spec.js +118 -6
- package/es/Accordion/__tests__/__snapshots__/Accordion.spec.js.snap +344 -2
- package/es/Accordion/__tests__/__snapshots__/AccordionItem.spec.js.snap +155 -3
- package/es/Animation/__tests__/Animation.spec.js +28 -4
- package/es/Animation/__tests__/__snapshots__/Animation.spec.js.snap +92 -2
- package/es/Button/css/Button.module.css +2 -3
- package/es/CheckBox/CheckBox.js +1 -1
- package/es/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +1 -1
- package/es/DateTime/DateTime.module.css +2 -2
- package/es/DateTime/__tests__/CalendarView.spec.js +70 -3
- package/es/DateTime/__tests__/DateTime.spec.js +89 -6
- package/es/DateTime/__tests__/DateTimePopupFooter.spec.js +20 -2
- package/es/DateTime/__tests__/DateTimePopupHeader.spec.js +29 -2
- package/es/DateTime/__tests__/DateWidget.spec.js +34 -2
- package/es/DateTime/__tests__/DaysRow.spec.js +19 -3
- package/es/DateTime/__tests__/Time.spec.js +50 -3
- package/es/DateTime/__tests__/YearView.spec.js +60 -3
- package/es/DateTime/__tests__/__snapshots__/CalendarView.spec.js.snap +2907 -170
- package/es/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +4392 -108
- package/es/DateTime/__tests__/__snapshots__/DateTimePopupFooter.spec.js.snap +67 -1
- package/es/DateTime/__tests__/__snapshots__/DateTimePopupHeader.spec.js.snap +187 -1
- package/es/DateTime/__tests__/__snapshots__/DateWidget.spec.js.snap +265 -1
- package/es/DateTime/__tests__/__snapshots__/DaysRow.spec.js.snap +155 -2
- package/es/DateTime/__tests__/__snapshots__/Time.spec.js.snap +522 -5
- package/es/DateTime/__tests__/__snapshots__/YearView.spec.js.snap +540 -0
- package/es/DropBox/DropBoxElement/css/DropBoxElement.module.css +1 -4
- package/es/Heading/Heading.module.css +1 -1
- package/es/Heading/__tests__/Heading.spec.js +57 -3
- package/es/Heading/__tests__/__snapshots__/Heading.spec.js.snap +87 -14
- package/es/ListItem/__tests__/ListContainer.spec.js +228 -1
- package/es/ListItem/__tests__/ListItem.spec.js +359 -1
- package/es/ListItem/__tests__/ListItemWithAvatar.spec.js +390 -1
- package/es/ListItem/__tests__/ListItemWithCheckBox.spec.js +214 -1
- package/es/ListItem/__tests__/ListItemWithIcon.spec.js +303 -1
- package/es/ListItem/__tests__/ListItemWithRadio.spec.js +230 -1
- package/es/ListItem/__tests__/__snapshots__/ListContainer.spec.js.snap +602 -0
- package/es/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +1807 -0
- package/es/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +2703 -0
- package/es/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +2909 -0
- package/es/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +2009 -0
- package/es/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +3070 -0
- package/es/MultiSelect/MultiSelect.module.css +1 -2
- package/es/MultiSelect/__tests__/AdvancedGroupMultiSelect.spec.js +671 -1
- package/es/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +730 -1
- package/es/MultiSelect/__tests__/EmptyState.spec.js +268 -1
- package/es/MultiSelect/__tests__/MultiSelect.spec.js +889 -2
- package/es/MultiSelect/__tests__/MultiSelectHeader.spec.js +50 -1
- package/es/MultiSelect/__tests__/MultiSelectWithAvatar.spec.js +487 -1
- package/es/MultiSelect/__tests__/SelectedOptions.spec.js +291 -1
- package/es/MultiSelect/__tests__/Suggestions.spec.js +370 -2
- package/es/MultiSelect/__tests__/__snapshots__/AdvancedGroupMultiSelect.spec.js.snap +11785 -0
- package/es/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +12083 -0
- package/es/MultiSelect/__tests__/__snapshots__/EmptyState.spec.js.snap +253 -0
- package/es/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +14052 -0
- package/es/MultiSelect/__tests__/__snapshots__/MultiSelectHeader.spec.js.snap +136 -0
- package/es/MultiSelect/__tests__/__snapshots__/MultiSelectWithAvatar.spec.js.snap +11506 -0
- package/es/MultiSelect/__tests__/__snapshots__/SelectedOptions.spec.js.snap +1382 -0
- package/es/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +3611 -0
- package/es/PopOver/__tests__/PopOver.spec.js +141 -2
- package/es/PopOver/__tests__/__snapshots__/PopOver.spec.js.snap +1260 -0
- package/es/ResponsiveDropBox/__tests__/ResponsiveDropBox.spec.js +212 -1
- package/es/ResponsiveDropBox/__tests__/__snapshots__/ResponsiveDropBox.spec.js.snap +1802 -0
- package/es/Tab/Tabs.module.css +1 -2
- package/es/Tab/__tests__/Tab.spec.js +249 -1
- package/es/Tab/__tests__/TabContent.spec.js +34 -1
- package/es/Tab/__tests__/TabContentWrapper.spec.js +72 -1
- package/es/Tab/__tests__/TabWrapper.spec.js +163 -1
- package/es/Tab/__tests__/Tabs.spec.js +681 -1
- package/es/Tab/__tests__/__snapshots__/Tab.spec.js.snap +1049 -0
- package/es/Tab/__tests__/__snapshots__/TabContent.spec.js.snap +99 -0
- package/es/Tab/__tests__/__snapshots__/TabContentWrapper.spec.js.snap +121 -0
- package/es/Tab/__tests__/__snapshots__/TabWrapper.spec.js.snap +2002 -0
- package/es/Tab/__tests__/__snapshots__/Tabs.spec.js.snap +11053 -0
- package/es/Textarea/Textarea.module.css +1 -1
- package/es/Tooltip/Tooltip.module.css +1 -2
- package/es/Tooltip/__tests__/Tooltip.spec.js +590 -0
- package/es/Tooltip/__tests__/__snapshots__/Tooltip.spec.js.snap +813 -0
- package/es/Typography/css/Typography.module.css +8 -7
- package/es/common/common.module.css +4 -4
- package/lib/Accordion/__tests__/Accordion.spec.js +122 -2
- package/lib/Accordion/__tests__/AccordionItem.spec.js +126 -4
- package/lib/Accordion/__tests__/__snapshots__/Accordion.spec.js.snap +344 -2
- package/lib/Accordion/__tests__/__snapshots__/AccordionItem.spec.js.snap +155 -3
- package/lib/Animation/__tests__/Animation.spec.js +31 -5
- package/lib/Animation/__tests__/__snapshots__/Animation.spec.js.snap +92 -2
- package/lib/Button/css/Button.module.css +2 -3
- package/lib/CheckBox/CheckBox.js +1 -1
- package/lib/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +1 -1
- package/lib/DateTime/DateTime.module.css +2 -2
- package/lib/DateTime/__tests__/CalendarView.spec.js +71 -2
- package/lib/DateTime/__tests__/DateTime.spec.js +92 -6
- package/lib/DateTime/__tests__/DateTimePopupFooter.spec.js +21 -1
- package/lib/DateTime/__tests__/DateTimePopupHeader.spec.js +30 -1
- package/lib/DateTime/__tests__/DateWidget.spec.js +35 -1
- package/lib/DateTime/__tests__/DaysRow.spec.js +20 -2
- package/lib/DateTime/__tests__/Time.spec.js +51 -2
- package/lib/DateTime/__tests__/YearView.spec.js +61 -2
- package/lib/DateTime/__tests__/__snapshots__/CalendarView.spec.js.snap +2907 -170
- package/lib/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +4392 -108
- package/lib/DateTime/__tests__/__snapshots__/DateTimePopupFooter.spec.js.snap +67 -1
- package/lib/DateTime/__tests__/__snapshots__/DateTimePopupHeader.spec.js.snap +187 -1
- package/lib/DateTime/__tests__/__snapshots__/DateWidget.spec.js.snap +265 -1
- package/lib/DateTime/__tests__/__snapshots__/DaysRow.spec.js.snap +155 -2
- package/lib/DateTime/__tests__/__snapshots__/Time.spec.js.snap +522 -5
- package/lib/DateTime/__tests__/__snapshots__/YearView.spec.js.snap +540 -0
- package/lib/DropBox/DropBoxElement/css/DropBoxElement.module.css +1 -4
- package/lib/Heading/Heading.module.css +1 -1
- package/lib/Heading/__tests__/Heading.spec.js +60 -4
- package/lib/Heading/__tests__/__snapshots__/Heading.spec.js.snap +87 -14
- package/lib/ListItem/__tests__/ListContainer.spec.js +229 -0
- package/lib/ListItem/__tests__/ListItem.spec.js +362 -0
- package/lib/ListItem/__tests__/ListItemWithAvatar.spec.js +391 -0
- package/lib/ListItem/__tests__/ListItemWithCheckBox.spec.js +215 -0
- package/lib/ListItem/__tests__/ListItemWithIcon.spec.js +304 -0
- package/lib/ListItem/__tests__/ListItemWithRadio.spec.js +231 -0
- package/lib/ListItem/__tests__/__snapshots__/ListContainer.spec.js.snap +602 -0
- package/lib/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +1807 -0
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +2703 -0
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +2909 -0
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +2009 -0
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +3070 -0
- package/lib/MultiSelect/MultiSelect.module.css +1 -2
- package/lib/MultiSelect/__tests__/AdvancedGroupMultiSelect.spec.js +692 -0
- package/lib/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +741 -0
- package/lib/MultiSelect/__tests__/EmptyState.spec.js +273 -0
- package/lib/MultiSelect/__tests__/MultiSelect.spec.js +910 -0
- package/lib/MultiSelect/__tests__/MultiSelectHeader.spec.js +51 -0
- package/lib/MultiSelect/__tests__/MultiSelectWithAvatar.spec.js +497 -0
- package/lib/MultiSelect/__tests__/SelectedOptions.spec.js +305 -0
- package/lib/MultiSelect/__tests__/Suggestions.spec.js +375 -0
- package/lib/MultiSelect/__tests__/__snapshots__/AdvancedGroupMultiSelect.spec.js.snap +11785 -0
- package/lib/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +12083 -0
- package/lib/MultiSelect/__tests__/__snapshots__/EmptyState.spec.js.snap +253 -0
- package/lib/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +14052 -0
- package/lib/MultiSelect/__tests__/__snapshots__/MultiSelectHeader.spec.js.snap +136 -0
- package/lib/MultiSelect/__tests__/__snapshots__/MultiSelectWithAvatar.spec.js.snap +11506 -0
- package/lib/MultiSelect/__tests__/__snapshots__/SelectedOptions.spec.js.snap +1382 -0
- package/lib/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +3611 -0
- package/lib/PopOver/__tests__/PopOver.spec.js +150 -1
- package/lib/PopOver/__tests__/__snapshots__/PopOver.spec.js.snap +1260 -0
- package/lib/ResponsiveDropBox/__tests__/ResponsiveDropBox.spec.js +213 -0
- package/lib/ResponsiveDropBox/__tests__/__snapshots__/ResponsiveDropBox.spec.js.snap +1802 -0
- package/lib/Tab/Tabs.module.css +1 -2
- package/lib/Tab/__tests__/Tab.spec.js +250 -0
- package/lib/Tab/__tests__/TabContent.spec.js +35 -0
- package/lib/Tab/__tests__/TabContentWrapper.spec.js +76 -0
- package/lib/Tab/__tests__/TabWrapper.spec.js +174 -0
- package/lib/Tab/__tests__/Tabs.spec.js +741 -0
- package/lib/Tab/__tests__/__snapshots__/Tab.spec.js.snap +1049 -0
- package/lib/Tab/__tests__/__snapshots__/TabContent.spec.js.snap +99 -0
- package/lib/Tab/__tests__/__snapshots__/TabContentWrapper.spec.js.snap +121 -0
- package/lib/Tab/__tests__/__snapshots__/TabWrapper.spec.js.snap +2002 -0
- package/lib/Tab/__tests__/__snapshots__/Tabs.spec.js.snap +11053 -0
- package/lib/Textarea/Textarea.module.css +1 -1
- package/lib/Tooltip/Tooltip.module.css +1 -2
- package/lib/Tooltip/__tests__/Tooltip.spec.js +629 -0
- package/lib/Tooltip/__tests__/__snapshots__/Tooltip.spec.js.snap +813 -0
- package/lib/Typography/css/Typography.module.css +8 -7
- package/lib/common/common.module.css +4 -4
- package/package.json +6 -5
|
@@ -1,6 +1,35 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
1
3
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import MultiSelect from "../MultiSelect";
|
|
4
|
+
import { render, cleanup, fireEvent } from '@testing-library/react';
|
|
5
|
+
import MultiSelect from "../MultiSelect"; // the real Virtualizer measures the DOM (0 in jsdom); mocked to render the first rows synchronously
|
|
6
|
+
|
|
7
|
+
jest.mock('@zohodesk/virtualizer', () => {
|
|
8
|
+
const React = require('react');
|
|
9
|
+
|
|
10
|
+
return { ...jest.requireActual('@zohodesk/virtualizer'),
|
|
11
|
+
Virtualizer: function MockVirtualizer({
|
|
12
|
+
elementRenderer,
|
|
13
|
+
elementsCount,
|
|
14
|
+
dataId
|
|
15
|
+
}) {
|
|
16
|
+
const items = [];
|
|
17
|
+
|
|
18
|
+
for (let index = 0; index < Math.min(elementsCount, 3); index++) {
|
|
19
|
+
items.push( /*#__PURE__*/React.createElement(React.Fragment, {
|
|
20
|
+
key: index
|
|
21
|
+
}, elementRenderer({
|
|
22
|
+
index,
|
|
23
|
+
ref: () => {}
|
|
24
|
+
})));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
"data-id": dataId
|
|
29
|
+
}, items);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
});
|
|
4
33
|
const options = [{
|
|
5
34
|
id: 1,
|
|
6
35
|
text: 'custom 1',
|
|
@@ -33,6 +62,7 @@ const options = [{
|
|
|
33
62
|
const testData = ['text1', 'text2', 'text3', 'text4', 'text5', 'text6', 'text7', 'text8', 'text9', 'text10'];
|
|
34
63
|
const testSelectedData = ['text1', 'text2', 'text3'];
|
|
35
64
|
describe('MultiSelect', () => {
|
|
65
|
+
afterEach(() => cleanup());
|
|
36
66
|
test('rendering the defult props', () => {
|
|
37
67
|
const {
|
|
38
68
|
asFragment
|
|
@@ -81,4 +111,861 @@ describe('MultiSelect', () => {
|
|
|
81
111
|
}));
|
|
82
112
|
expect(asFragment()).toMatchSnapshot();
|
|
83
113
|
});
|
|
114
|
+
const menuOptions = [{
|
|
115
|
+
id: 'option1',
|
|
116
|
+
text: 'Option 1'
|
|
117
|
+
}, {
|
|
118
|
+
id: 'option2',
|
|
119
|
+
text: 'Option 2'
|
|
120
|
+
}, {
|
|
121
|
+
id: 'option3',
|
|
122
|
+
text: 'Option 3'
|
|
123
|
+
}]; // options, selectedOptions, onChange and emptyMessage are required without defaults
|
|
124
|
+
|
|
125
|
+
const getRequiredProps = () => ({
|
|
126
|
+
emptyMessage: 'No options',
|
|
127
|
+
onChange: jest.fn(),
|
|
128
|
+
options: menuOptions,
|
|
129
|
+
selectedOptions: []
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const getSearchInput = container => container.querySelector('[data-id="multiSelect_textBox"]'); // selected options and clear icon
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
test('Render with selectedOptions', () => {
|
|
136
|
+
const {
|
|
137
|
+
asFragment
|
|
138
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
139
|
+
selectedOptions: ['option1']
|
|
140
|
+
})));
|
|
141
|
+
expect(asFragment()).toMatchSnapshot();
|
|
142
|
+
});
|
|
143
|
+
test('Render with two selectedOptions', () => {
|
|
144
|
+
const {
|
|
145
|
+
asFragment
|
|
146
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
147
|
+
selectedOptions: ['option1', 'option2']
|
|
148
|
+
})));
|
|
149
|
+
expect(asFragment()).toMatchSnapshot();
|
|
150
|
+
});
|
|
151
|
+
test('Render with selectedOptions not in options', () => {
|
|
152
|
+
const {
|
|
153
|
+
asFragment
|
|
154
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
155
|
+
selectedOptions: ['unknown']
|
|
156
|
+
})));
|
|
157
|
+
expect(asFragment()).toMatchSnapshot();
|
|
158
|
+
});
|
|
159
|
+
test('Render with selectedOptions not in options and allowValueFallback=false', () => {
|
|
160
|
+
const {
|
|
161
|
+
asFragment
|
|
162
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
163
|
+
selectedOptions: ['unknown'],
|
|
164
|
+
allowValueFallback: false
|
|
165
|
+
})));
|
|
166
|
+
expect(asFragment()).toMatchSnapshot();
|
|
167
|
+
});
|
|
168
|
+
test('Render with limit as 2 and three selectedOptions', () => {
|
|
169
|
+
const {
|
|
170
|
+
asFragment
|
|
171
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
172
|
+
selectedOptions: ['option1', 'option2', 'option3'],
|
|
173
|
+
limit: 2
|
|
174
|
+
})));
|
|
175
|
+
expect(asFragment()).toMatchSnapshot();
|
|
176
|
+
});
|
|
177
|
+
test('Render with isReadOnly', () => {
|
|
178
|
+
const {
|
|
179
|
+
asFragment
|
|
180
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
181
|
+
selectedOptions: ['option1', 'option2'],
|
|
182
|
+
isReadOnly: true
|
|
183
|
+
})));
|
|
184
|
+
expect(asFragment()).toMatchSnapshot();
|
|
185
|
+
});
|
|
186
|
+
test('Render with disableAction', () => {
|
|
187
|
+
const {
|
|
188
|
+
asFragment
|
|
189
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
190
|
+
selectedOptions: ['option1', 'option2'],
|
|
191
|
+
disableAction: true
|
|
192
|
+
})));
|
|
193
|
+
expect(asFragment()).toMatchSnapshot();
|
|
194
|
+
});
|
|
195
|
+
test('Render with isDisabled and title', () => {
|
|
196
|
+
const {
|
|
197
|
+
asFragment
|
|
198
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
199
|
+
selectedOptions: ['option1'],
|
|
200
|
+
isDisabled: true,
|
|
201
|
+
title: "Disabled title"
|
|
202
|
+
})));
|
|
203
|
+
expect(asFragment()).toMatchSnapshot();
|
|
204
|
+
});
|
|
205
|
+
test('Render with disabledOptions leaving one enabled selected option', () => {
|
|
206
|
+
const {
|
|
207
|
+
asFragment
|
|
208
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
209
|
+
selectedOptions: ['option1', 'option2'],
|
|
210
|
+
disabledOptions: ['option1']
|
|
211
|
+
})));
|
|
212
|
+
expect(asFragment()).toMatchSnapshot();
|
|
213
|
+
});
|
|
214
|
+
test('Render with disabledOptions leaving two enabled selected options', () => {
|
|
215
|
+
const {
|
|
216
|
+
asFragment
|
|
217
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
218
|
+
selectedOptions: ['option1', 'option2', 'option3'],
|
|
219
|
+
disabledOptions: ['option1']
|
|
220
|
+
})));
|
|
221
|
+
expect(asFragment()).toMatchSnapshot();
|
|
222
|
+
}); // appearance
|
|
223
|
+
|
|
224
|
+
test('Render with size as xmedium', () => {
|
|
225
|
+
const {
|
|
226
|
+
asFragment
|
|
227
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
228
|
+
selectedOptions: ['option1'],
|
|
229
|
+
size: "xmedium"
|
|
230
|
+
})));
|
|
231
|
+
expect(asFragment()).toMatchSnapshot();
|
|
232
|
+
});
|
|
233
|
+
test.each(['small', 'xmedium'])('Render with textBoxSize as %s', textBoxSize => {
|
|
234
|
+
const {
|
|
235
|
+
asFragment
|
|
236
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
237
|
+
textBoxSize: textBoxSize
|
|
238
|
+
})));
|
|
239
|
+
expect(asFragment()).toMatchSnapshot();
|
|
240
|
+
});
|
|
241
|
+
test.each(['primary', 'secondary'])('Render with variant as %s', variant => {
|
|
242
|
+
const {
|
|
243
|
+
asFragment
|
|
244
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
245
|
+
variant: variant
|
|
246
|
+
})));
|
|
247
|
+
expect(asFragment()).toMatchSnapshot();
|
|
248
|
+
});
|
|
249
|
+
test.each(['transparent', 'dark'])('Render with borderColor as %s', borderColor => {
|
|
250
|
+
const {
|
|
251
|
+
asFragment
|
|
252
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
253
|
+
borderColor: borderColor
|
|
254
|
+
})));
|
|
255
|
+
expect(asFragment()).toMatchSnapshot();
|
|
256
|
+
});
|
|
257
|
+
test('Render with needBorder=false', () => {
|
|
258
|
+
const {
|
|
259
|
+
asFragment
|
|
260
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
261
|
+
needBorder: false
|
|
262
|
+
})));
|
|
263
|
+
expect(asFragment()).toMatchSnapshot();
|
|
264
|
+
});
|
|
265
|
+
test('Render with isFocus', () => {
|
|
266
|
+
const {
|
|
267
|
+
asFragment
|
|
268
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
269
|
+
isFocus: true
|
|
270
|
+
})));
|
|
271
|
+
expect(asFragment()).toMatchSnapshot();
|
|
272
|
+
});
|
|
273
|
+
test('Render with isFocus and isReadOnly', () => {
|
|
274
|
+
const {
|
|
275
|
+
asFragment
|
|
276
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
277
|
+
isFocus: true,
|
|
278
|
+
isReadOnly: true
|
|
279
|
+
})));
|
|
280
|
+
expect(asFragment()).toMatchSnapshot();
|
|
281
|
+
});
|
|
282
|
+
test('Render with needEffect=false', () => {
|
|
283
|
+
const {
|
|
284
|
+
asFragment
|
|
285
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
286
|
+
needEffect: false
|
|
287
|
+
})));
|
|
288
|
+
expect(asFragment()).toMatchSnapshot();
|
|
289
|
+
});
|
|
290
|
+
test('Render with palette as dark', () => {
|
|
291
|
+
const {
|
|
292
|
+
asFragment
|
|
293
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
294
|
+
selectedOptions: ['option1', 'option2'],
|
|
295
|
+
palette: "dark"
|
|
296
|
+
})));
|
|
297
|
+
expect(asFragment()).toMatchSnapshot();
|
|
298
|
+
});
|
|
299
|
+
test('Render with textBoxClass', () => {
|
|
300
|
+
const {
|
|
301
|
+
asFragment
|
|
302
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
303
|
+
textBoxClass: "custom-textbox"
|
|
304
|
+
})));
|
|
305
|
+
expect(asFragment()).toMatchSnapshot();
|
|
306
|
+
});
|
|
307
|
+
test('Render with customChildrenClass', () => {
|
|
308
|
+
const {
|
|
309
|
+
asFragment
|
|
310
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
311
|
+
customChildrenClass: "custom-children"
|
|
312
|
+
})));
|
|
313
|
+
expect(asFragment()).toMatchSnapshot();
|
|
314
|
+
});
|
|
315
|
+
test('Render with placeHolder', () => {
|
|
316
|
+
const {
|
|
317
|
+
asFragment
|
|
318
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
319
|
+
placeHolder: "Select options"
|
|
320
|
+
})));
|
|
321
|
+
expect(asFragment()).toMatchSnapshot();
|
|
322
|
+
}); // the placeholder is hidden once an option is selected
|
|
323
|
+
|
|
324
|
+
test('Render with placeHolder and selectedOptions', () => {
|
|
325
|
+
const {
|
|
326
|
+
asFragment
|
|
327
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
328
|
+
selectedOptions: ['option1'],
|
|
329
|
+
placeHolder: "Select options"
|
|
330
|
+
})));
|
|
331
|
+
expect(asFragment()).toMatchSnapshot();
|
|
332
|
+
});
|
|
333
|
+
test('Render with needAutoFocus', () => {
|
|
334
|
+
const {
|
|
335
|
+
asFragment
|
|
336
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
337
|
+
needAutoFocus: true
|
|
338
|
+
})));
|
|
339
|
+
expect(asFragment()).toMatchSnapshot();
|
|
340
|
+
});
|
|
341
|
+
test('Render with autoComplete', () => {
|
|
342
|
+
const {
|
|
343
|
+
asFragment
|
|
344
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
345
|
+
autoComplete: true
|
|
346
|
+
})));
|
|
347
|
+
expect(asFragment()).toMatchSnapshot();
|
|
348
|
+
}); // identification and accessibility
|
|
349
|
+
|
|
350
|
+
test('Render with dataId', () => {
|
|
351
|
+
const {
|
|
352
|
+
asFragment
|
|
353
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
354
|
+
dataId: "multi-select-dataId"
|
|
355
|
+
})));
|
|
356
|
+
expect(asFragment()).toMatchSnapshot();
|
|
357
|
+
});
|
|
358
|
+
test('Render with dataId and isDisabled', () => {
|
|
359
|
+
const {
|
|
360
|
+
asFragment
|
|
361
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
362
|
+
dataId: "multi-select-dataId",
|
|
363
|
+
isDisabled: true
|
|
364
|
+
})));
|
|
365
|
+
expect(asFragment()).toMatchSnapshot();
|
|
366
|
+
});
|
|
367
|
+
test('Render with dataId and isReadOnly', () => {
|
|
368
|
+
const {
|
|
369
|
+
asFragment
|
|
370
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
371
|
+
dataId: "multi-select-dataId",
|
|
372
|
+
isReadOnly: true
|
|
373
|
+
})));
|
|
374
|
+
expect(asFragment()).toMatchSnapshot();
|
|
375
|
+
});
|
|
376
|
+
test('Render with dataSelectorId', () => {
|
|
377
|
+
const {
|
|
378
|
+
asFragment
|
|
379
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
380
|
+
dataSelectorId: "multi-select-selector"
|
|
381
|
+
})));
|
|
382
|
+
expect(asFragment()).toMatchSnapshot();
|
|
383
|
+
});
|
|
384
|
+
test('Render with htmlId', () => {
|
|
385
|
+
const {
|
|
386
|
+
asFragment
|
|
387
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
388
|
+
htmlId: "multi-select-htmlId"
|
|
389
|
+
})));
|
|
390
|
+
expect(asFragment()).toMatchSnapshot();
|
|
391
|
+
});
|
|
392
|
+
test('Render with ariaErrorId', () => {
|
|
393
|
+
const {
|
|
394
|
+
asFragment
|
|
395
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
396
|
+
ariaErrorId: "multi-select-error"
|
|
397
|
+
})));
|
|
398
|
+
expect(asFragment()).toMatchSnapshot();
|
|
399
|
+
});
|
|
400
|
+
test('Render with setAriaId', () => {
|
|
401
|
+
const {
|
|
402
|
+
asFragment
|
|
403
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
404
|
+
setAriaId: "multi-select-aria"
|
|
405
|
+
})));
|
|
406
|
+
expect(asFragment()).toMatchSnapshot();
|
|
407
|
+
});
|
|
408
|
+
test('Render with a11y clearLabel and ariaLabelledby', () => {
|
|
409
|
+
const {
|
|
410
|
+
asFragment
|
|
411
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
412
|
+
selectedOptions: ['option1', 'option2'],
|
|
413
|
+
a11y: {
|
|
414
|
+
clearLabel: 'Clear selected',
|
|
415
|
+
ariaLabelledby: 'multi-select-label'
|
|
416
|
+
}
|
|
417
|
+
})));
|
|
418
|
+
expect(asFragment()).toMatchSnapshot();
|
|
419
|
+
});
|
|
420
|
+
test('Render with i18nKeys clearText', () => {
|
|
421
|
+
const {
|
|
422
|
+
asFragment
|
|
423
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
424
|
+
selectedOptions: ['option1', 'option2'],
|
|
425
|
+
i18nKeys: {
|
|
426
|
+
clearText: 'Remove all'
|
|
427
|
+
}
|
|
428
|
+
})));
|
|
429
|
+
expect(asFragment()).toMatchSnapshot();
|
|
430
|
+
});
|
|
431
|
+
test('Render with customProps TextBoxIconProps', () => {
|
|
432
|
+
const {
|
|
433
|
+
asFragment
|
|
434
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
435
|
+
customProps: {
|
|
436
|
+
TextBoxIconProps: {
|
|
437
|
+
name: 'multi-select-name',
|
|
438
|
+
maxLength: '10',
|
|
439
|
+
customProps: {
|
|
440
|
+
TextBoxProps: {
|
|
441
|
+
'data-custom-attr': 'true'
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
})));
|
|
447
|
+
expect(asFragment()).toMatchSnapshot();
|
|
448
|
+
}); // custom UI slots
|
|
449
|
+
|
|
450
|
+
test('Render with children', () => {
|
|
451
|
+
const {
|
|
452
|
+
asFragment
|
|
453
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, getRequiredProps(), /*#__PURE__*/React.createElement("span", null, "Custom child")));
|
|
454
|
+
expect(asFragment()).toMatchSnapshot();
|
|
455
|
+
});
|
|
456
|
+
test('Render with renderCustomClearComponent', () => {
|
|
457
|
+
const {
|
|
458
|
+
asFragment
|
|
459
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
460
|
+
selectedOptions: ['option1', 'option2'],
|
|
461
|
+
renderCustomClearComponent: ({
|
|
462
|
+
clearText,
|
|
463
|
+
isPopupOpened,
|
|
464
|
+
handleClearAll
|
|
465
|
+
}) => /*#__PURE__*/React.createElement("span", null, `${clearText} ${isPopupOpened} ${typeof handleClearAll}`)
|
|
466
|
+
})));
|
|
467
|
+
expect(asFragment()).toMatchSnapshot();
|
|
468
|
+
});
|
|
469
|
+
test('Render with renderCustomToggleIndicator as function', () => {
|
|
470
|
+
const {
|
|
471
|
+
asFragment
|
|
472
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
473
|
+
isReadOnly: true,
|
|
474
|
+
renderCustomToggleIndicator: ({
|
|
475
|
+
togglePopup,
|
|
476
|
+
isPopupOpened,
|
|
477
|
+
isReadOnly,
|
|
478
|
+
isDisabled
|
|
479
|
+
}) => /*#__PURE__*/React.createElement("span", null, `${typeof togglePopup} ${isPopupOpened} ${isReadOnly} ${isDisabled}`)
|
|
480
|
+
})));
|
|
481
|
+
expect(asFragment()).toMatchSnapshot();
|
|
482
|
+
});
|
|
483
|
+
test('Render with renderCustomToggleIndicator as node', () => {
|
|
484
|
+
const {
|
|
485
|
+
asFragment
|
|
486
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
487
|
+
renderCustomToggleIndicator: /*#__PURE__*/React.createElement("span", null, "Toggle indicator")
|
|
488
|
+
})));
|
|
489
|
+
expect(asFragment()).toMatchSnapshot();
|
|
490
|
+
}); // open menu
|
|
491
|
+
|
|
492
|
+
test('Render with isPopupOpen and isPopupReady', () => {
|
|
493
|
+
const {
|
|
494
|
+
asFragment
|
|
495
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
496
|
+
isPopupOpen: true,
|
|
497
|
+
isPopupReady: true
|
|
498
|
+
})));
|
|
499
|
+
expect(asFragment()).toMatchSnapshot();
|
|
500
|
+
});
|
|
501
|
+
test('Render with isPopupOpen, isPopupReady and isDisabled', () => {
|
|
502
|
+
const {
|
|
503
|
+
asFragment
|
|
504
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
505
|
+
isPopupOpen: true,
|
|
506
|
+
isPopupReady: true,
|
|
507
|
+
isDisabled: true
|
|
508
|
+
})));
|
|
509
|
+
expect(asFragment()).toMatchSnapshot();
|
|
510
|
+
});
|
|
511
|
+
test('Render with isPopupOpen, isPopupReady and isReadOnly', () => {
|
|
512
|
+
const {
|
|
513
|
+
asFragment
|
|
514
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
515
|
+
isPopupOpen: true,
|
|
516
|
+
isPopupReady: true,
|
|
517
|
+
isReadOnly: true
|
|
518
|
+
})));
|
|
519
|
+
expect(asFragment()).toMatchSnapshot();
|
|
520
|
+
});
|
|
521
|
+
test('Render with isPopupOpen, isPopupReady and disableAction', () => {
|
|
522
|
+
const {
|
|
523
|
+
asFragment
|
|
524
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
525
|
+
isPopupOpen: true,
|
|
526
|
+
isPopupReady: true,
|
|
527
|
+
disableAction: true
|
|
528
|
+
})));
|
|
529
|
+
expect(asFragment()).toMatchSnapshot();
|
|
530
|
+
});
|
|
531
|
+
test('Render with isPopupOpen, isPopupReady and selectedOptions', () => {
|
|
532
|
+
const {
|
|
533
|
+
asFragment
|
|
534
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
535
|
+
isPopupOpen: true,
|
|
536
|
+
isPopupReady: true,
|
|
537
|
+
selectedOptions: ['option1']
|
|
538
|
+
})));
|
|
539
|
+
expect(asFragment()).toMatchSnapshot();
|
|
540
|
+
});
|
|
541
|
+
test('Render with isPopupOpen, isPopupReady, selectedOptions and keepSelectedOptions', () => {
|
|
542
|
+
const {
|
|
543
|
+
asFragment
|
|
544
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
545
|
+
isPopupOpen: true,
|
|
546
|
+
isPopupReady: true,
|
|
547
|
+
selectedOptions: ['option1'],
|
|
548
|
+
keepSelectedOptions: true
|
|
549
|
+
})));
|
|
550
|
+
expect(asFragment()).toMatchSnapshot();
|
|
551
|
+
});
|
|
552
|
+
test('Render with isPopupOpen, isPopupReady and disabledOptions', () => {
|
|
553
|
+
const {
|
|
554
|
+
asFragment
|
|
555
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
556
|
+
isPopupOpen: true,
|
|
557
|
+
isPopupReady: true,
|
|
558
|
+
disabledOptions: ['option2']
|
|
559
|
+
})));
|
|
560
|
+
expect(asFragment()).toMatchSnapshot();
|
|
561
|
+
});
|
|
562
|
+
test('Render with isPopupOpen, isPopupReady and secondaryField', () => {
|
|
563
|
+
const {
|
|
564
|
+
asFragment
|
|
565
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
566
|
+
isPopupOpen: true,
|
|
567
|
+
isPopupReady: true,
|
|
568
|
+
options: [{
|
|
569
|
+
id: 'option1',
|
|
570
|
+
text: 'Option 1',
|
|
571
|
+
secondary: 'Secondary 1'
|
|
572
|
+
}],
|
|
573
|
+
secondaryField: "secondary"
|
|
574
|
+
})));
|
|
575
|
+
expect(asFragment()).toMatchSnapshot();
|
|
576
|
+
});
|
|
577
|
+
test('Render with isPopupOpen, isPopupReady, valueField and textField', () => {
|
|
578
|
+
const {
|
|
579
|
+
asFragment
|
|
580
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
581
|
+
isPopupOpen: true,
|
|
582
|
+
isPopupReady: true,
|
|
583
|
+
options: [{
|
|
584
|
+
key: 'k1',
|
|
585
|
+
label: 'Label 1'
|
|
586
|
+
}, {
|
|
587
|
+
key: 'k2',
|
|
588
|
+
label: 'Label 2'
|
|
589
|
+
}],
|
|
590
|
+
valueField: "key",
|
|
591
|
+
textField: "label"
|
|
592
|
+
})));
|
|
593
|
+
expect(asFragment()).toMatchSnapshot();
|
|
594
|
+
});
|
|
595
|
+
test('Render with isPopupOpen, isPopupReady and string options', () => {
|
|
596
|
+
const {
|
|
597
|
+
asFragment
|
|
598
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
599
|
+
isPopupOpen: true,
|
|
600
|
+
isPopupReady: true,
|
|
601
|
+
options: ['String 1', 'String 2']
|
|
602
|
+
})));
|
|
603
|
+
expect(asFragment()).toMatchSnapshot();
|
|
604
|
+
});
|
|
605
|
+
test('Render with isPopupOpen, isPopupReady and customProps SuggestionsProps', () => {
|
|
606
|
+
const {
|
|
607
|
+
asFragment
|
|
608
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
609
|
+
isPopupOpen: true,
|
|
610
|
+
isPopupReady: true,
|
|
611
|
+
customProps: {
|
|
612
|
+
SuggestionsProps: {
|
|
613
|
+
needTick: true,
|
|
614
|
+
listItemSize: 'small'
|
|
615
|
+
}
|
|
616
|
+
},
|
|
617
|
+
selectedOptions: ['option1'],
|
|
618
|
+
keepSelectedOptions: true
|
|
619
|
+
})));
|
|
620
|
+
expect(asFragment()).toMatchSnapshot();
|
|
621
|
+
});
|
|
622
|
+
test('Render with isPopupOpen, isPopupReady and isVirtualizerEnabled', () => {
|
|
623
|
+
const {
|
|
624
|
+
asFragment
|
|
625
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
626
|
+
isPopupOpen: true,
|
|
627
|
+
isPopupReady: true,
|
|
628
|
+
isVirtualizerEnabled: true
|
|
629
|
+
})));
|
|
630
|
+
expect(asFragment()).toMatchSnapshot();
|
|
631
|
+
}); // select all header
|
|
632
|
+
|
|
633
|
+
test('Render with isPopupOpen, isPopupReady and needSelectAll', () => {
|
|
634
|
+
const {
|
|
635
|
+
asFragment
|
|
636
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
637
|
+
isPopupOpen: true,
|
|
638
|
+
isPopupReady: true,
|
|
639
|
+
needSelectAll: true
|
|
640
|
+
})));
|
|
641
|
+
expect(asFragment()).toMatchSnapshot();
|
|
642
|
+
});
|
|
643
|
+
test('Render with isPopupOpen, isPopupReady, needSelectAll and selectAllText', () => {
|
|
644
|
+
const {
|
|
645
|
+
asFragment
|
|
646
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
647
|
+
isPopupOpen: true,
|
|
648
|
+
isPopupReady: true,
|
|
649
|
+
needSelectAll: true,
|
|
650
|
+
selectAllText: "Select every option"
|
|
651
|
+
})));
|
|
652
|
+
expect(asFragment()).toMatchSnapshot();
|
|
653
|
+
}); // select all is hidden once a limit is set
|
|
654
|
+
|
|
655
|
+
test('Render with isPopupOpen, isPopupReady, needSelectAll and limit', () => {
|
|
656
|
+
const {
|
|
657
|
+
asFragment
|
|
658
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
659
|
+
isPopupOpen: true,
|
|
660
|
+
isPopupReady: true,
|
|
661
|
+
needSelectAll: true,
|
|
662
|
+
limit: 3
|
|
663
|
+
})));
|
|
664
|
+
expect(asFragment()).toMatchSnapshot();
|
|
665
|
+
}); // limit
|
|
666
|
+
|
|
667
|
+
test('Render with isPopupOpen, isPopupReady, limit reached and default limit message', () => {
|
|
668
|
+
const {
|
|
669
|
+
asFragment
|
|
670
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
671
|
+
isPopupOpen: true,
|
|
672
|
+
isPopupReady: true,
|
|
673
|
+
selectedOptions: ['option1'],
|
|
674
|
+
limit: 1
|
|
675
|
+
})));
|
|
676
|
+
expect(asFragment()).toMatchSnapshot();
|
|
677
|
+
});
|
|
678
|
+
test('Render with isPopupOpen, isPopupReady, limit reached and i18nKeys limitReachedMessage', () => {
|
|
679
|
+
const {
|
|
680
|
+
asFragment
|
|
681
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
682
|
+
isPopupOpen: true,
|
|
683
|
+
isPopupReady: true,
|
|
684
|
+
selectedOptions: ['option1'],
|
|
685
|
+
limit: 1,
|
|
686
|
+
i18nKeys: {
|
|
687
|
+
limitReachedMessage: 'Only one allowed'
|
|
688
|
+
}
|
|
689
|
+
})));
|
|
690
|
+
expect(asFragment()).toMatchSnapshot();
|
|
691
|
+
}); // loaders
|
|
692
|
+
|
|
693
|
+
test('Render with isPopupOpen, isPopupReady and isLoading', () => {
|
|
694
|
+
const {
|
|
695
|
+
asFragment
|
|
696
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
697
|
+
isPopupOpen: true,
|
|
698
|
+
isPopupReady: true,
|
|
699
|
+
isLoading: true
|
|
700
|
+
})));
|
|
701
|
+
expect(asFragment()).toMatchSnapshot();
|
|
702
|
+
});
|
|
703
|
+
test('Render with isPopupOpen, isPopupReady, isLoading and shouldUseInternalLoader=false', () => {
|
|
704
|
+
const {
|
|
705
|
+
asFragment
|
|
706
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
707
|
+
isPopupOpen: true,
|
|
708
|
+
isPopupReady: true,
|
|
709
|
+
isLoading: true,
|
|
710
|
+
shouldUseInternalLoader: false
|
|
711
|
+
})));
|
|
712
|
+
expect(asFragment()).toMatchSnapshot();
|
|
713
|
+
});
|
|
714
|
+
test('Render with isPopupOpen, isPopupReady, isLoading, shouldUseInternalLoader=false and no options', () => {
|
|
715
|
+
const {
|
|
716
|
+
asFragment
|
|
717
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
718
|
+
options: [],
|
|
719
|
+
isPopupOpen: true,
|
|
720
|
+
isPopupReady: true,
|
|
721
|
+
isLoading: true,
|
|
722
|
+
shouldUseInternalLoader: false
|
|
723
|
+
})));
|
|
724
|
+
expect(asFragment()).toMatchSnapshot();
|
|
725
|
+
});
|
|
726
|
+
test('Render with isPopupOpen, isPopupReady and isSearching', () => {
|
|
727
|
+
const {
|
|
728
|
+
asFragment
|
|
729
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
730
|
+
isPopupOpen: true,
|
|
731
|
+
isPopupReady: true,
|
|
732
|
+
isSearching: true
|
|
733
|
+
})));
|
|
734
|
+
expect(asFragment()).toMatchSnapshot();
|
|
735
|
+
});
|
|
736
|
+
test('Render with isPopupOpen, isPopupReady, isSearching and i18nKeys searchText', () => {
|
|
737
|
+
const {
|
|
738
|
+
asFragment
|
|
739
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
740
|
+
isPopupOpen: true,
|
|
741
|
+
isPopupReady: true,
|
|
742
|
+
isSearching: true,
|
|
743
|
+
i18nKeys: {
|
|
744
|
+
searchText: 'Looking for options'
|
|
745
|
+
}
|
|
746
|
+
})));
|
|
747
|
+
expect(asFragment()).toMatchSnapshot();
|
|
748
|
+
});
|
|
749
|
+
test('Render with isPopupOpen, isPopupReady, isSearching and palette as dark', () => {
|
|
750
|
+
const {
|
|
751
|
+
asFragment
|
|
752
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
753
|
+
isPopupOpen: true,
|
|
754
|
+
isPopupReady: true,
|
|
755
|
+
isSearching: true,
|
|
756
|
+
palette: "dark"
|
|
757
|
+
})));
|
|
758
|
+
expect(asFragment()).toMatchSnapshot();
|
|
759
|
+
}); // empty states
|
|
760
|
+
|
|
761
|
+
test('Render with isPopupOpen, isPopupReady and no options', () => {
|
|
762
|
+
const {
|
|
763
|
+
asFragment
|
|
764
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
765
|
+
options: [],
|
|
766
|
+
isPopupOpen: true,
|
|
767
|
+
isPopupReady: true
|
|
768
|
+
})));
|
|
769
|
+
expect(asFragment()).toMatchSnapshot();
|
|
770
|
+
});
|
|
771
|
+
test('Render with isPopupOpen, isPopupReady, no options and emptyMessage', () => {
|
|
772
|
+
const {
|
|
773
|
+
asFragment
|
|
774
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
775
|
+
options: [],
|
|
776
|
+
isPopupOpen: true,
|
|
777
|
+
isPopupReady: true,
|
|
778
|
+
emptyMessage: "Nothing to select"
|
|
779
|
+
})));
|
|
780
|
+
expect(asFragment()).toMatchSnapshot();
|
|
781
|
+
});
|
|
782
|
+
test('Render with isPopupOpen, isPopupReady, no options and i18nKeys emptyText', () => {
|
|
783
|
+
const {
|
|
784
|
+
asFragment
|
|
785
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
786
|
+
options: [],
|
|
787
|
+
isPopupOpen: true,
|
|
788
|
+
isPopupReady: true,
|
|
789
|
+
i18nKeys: {
|
|
790
|
+
emptyText: 'Empty from i18n'
|
|
791
|
+
}
|
|
792
|
+
})));
|
|
793
|
+
expect(asFragment()).toMatchSnapshot();
|
|
794
|
+
});
|
|
795
|
+
test('Render with isPopupOpen, isPopupReady, no options and renderCustomEmptyState', () => {
|
|
796
|
+
const {
|
|
797
|
+
asFragment
|
|
798
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
799
|
+
options: [],
|
|
800
|
+
isPopupOpen: true,
|
|
801
|
+
isPopupReady: true,
|
|
802
|
+
renderCustomEmptyState: () => /*#__PURE__*/React.createElement("span", null, "Custom empty state")
|
|
803
|
+
})));
|
|
804
|
+
expect(asFragment()).toMatchSnapshot();
|
|
805
|
+
});
|
|
806
|
+
test('Render with isPopupOpen, isPopupReady and all options selected', () => {
|
|
807
|
+
const {
|
|
808
|
+
asFragment
|
|
809
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
810
|
+
isPopupOpen: true,
|
|
811
|
+
isPopupReady: true,
|
|
812
|
+
selectedOptions: ['option1', 'option2', 'option3']
|
|
813
|
+
})));
|
|
814
|
+
expect(asFragment()).toMatchSnapshot();
|
|
815
|
+
});
|
|
816
|
+
test('Render with isPopupOpen, isPopupReady, all options selected and noMoreOptionsMessage', () => {
|
|
817
|
+
const {
|
|
818
|
+
asFragment
|
|
819
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
820
|
+
isPopupOpen: true,
|
|
821
|
+
isPopupReady: true,
|
|
822
|
+
selectedOptions: ['option1', 'option2', 'option3'],
|
|
823
|
+
noMoreOptionsMessage: "No more to pick"
|
|
824
|
+
})));
|
|
825
|
+
expect(asFragment()).toMatchSnapshot();
|
|
826
|
+
}); // typed search
|
|
827
|
+
|
|
828
|
+
test('Render with isPopupOpen, isPopupReady and search text matching an option', () => {
|
|
829
|
+
const {
|
|
830
|
+
asFragment,
|
|
831
|
+
container
|
|
832
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
833
|
+
isPopupOpen: true,
|
|
834
|
+
isPopupReady: true
|
|
835
|
+
})));
|
|
836
|
+
fireEvent.change(getSearchInput(container), {
|
|
837
|
+
target: {
|
|
838
|
+
value: 'Option 2'
|
|
839
|
+
}
|
|
840
|
+
});
|
|
841
|
+
expect(asFragment()).toMatchSnapshot();
|
|
842
|
+
});
|
|
843
|
+
test('Render with isPopupOpen, isPopupReady and search text matching no option', () => {
|
|
844
|
+
const {
|
|
845
|
+
asFragment,
|
|
846
|
+
container
|
|
847
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
848
|
+
isPopupOpen: true,
|
|
849
|
+
isPopupReady: true
|
|
850
|
+
})));
|
|
851
|
+
fireEvent.change(getSearchInput(container), {
|
|
852
|
+
target: {
|
|
853
|
+
value: 'zzz'
|
|
854
|
+
}
|
|
855
|
+
});
|
|
856
|
+
expect(asFragment()).toMatchSnapshot();
|
|
857
|
+
});
|
|
858
|
+
test('Render with isPopupOpen, isPopupReady, search text matching no option and searchEmptyMessage', () => {
|
|
859
|
+
const {
|
|
860
|
+
asFragment,
|
|
861
|
+
container
|
|
862
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
863
|
+
isPopupOpen: true,
|
|
864
|
+
isPopupReady: true,
|
|
865
|
+
searchEmptyMessage: "No matches found"
|
|
866
|
+
})));
|
|
867
|
+
fireEvent.change(getSearchInput(container), {
|
|
868
|
+
target: {
|
|
869
|
+
value: 'zzz'
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
expect(asFragment()).toMatchSnapshot();
|
|
873
|
+
});
|
|
874
|
+
test('Render with isPopupOpen, isPopupReady, search text and needLocalSearch=false', () => {
|
|
875
|
+
const {
|
|
876
|
+
asFragment,
|
|
877
|
+
container
|
|
878
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
879
|
+
isPopupOpen: true,
|
|
880
|
+
isPopupReady: true,
|
|
881
|
+
needLocalSearch: false
|
|
882
|
+
})));
|
|
883
|
+
fireEvent.change(getSearchInput(container), {
|
|
884
|
+
target: {
|
|
885
|
+
value: 'zzz'
|
|
886
|
+
}
|
|
887
|
+
});
|
|
888
|
+
expect(asFragment()).toMatchSnapshot();
|
|
889
|
+
}); // drop box
|
|
890
|
+
|
|
891
|
+
test.each(['medium', 'large'])('Render with isPopupOpen, isPopupReady and dropBoxSize as %s', dropBoxSize => {
|
|
892
|
+
const {
|
|
893
|
+
asFragment
|
|
894
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
895
|
+
isPopupOpen: true,
|
|
896
|
+
isPopupReady: true,
|
|
897
|
+
dropBoxSize: dropBoxSize
|
|
898
|
+
})));
|
|
899
|
+
expect(asFragment()).toMatchSnapshot();
|
|
900
|
+
});
|
|
901
|
+
test('Render with isPopupOpen, isPopupReady and boxSize as medium', () => {
|
|
902
|
+
const {
|
|
903
|
+
asFragment
|
|
904
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
905
|
+
isPopupOpen: true,
|
|
906
|
+
isPopupReady: true,
|
|
907
|
+
boxSize: "medium"
|
|
908
|
+
})));
|
|
909
|
+
expect(asFragment()).toMatchSnapshot();
|
|
910
|
+
});
|
|
911
|
+
test('Render with isPopupOpen, isPopupReady and palette as dark', () => {
|
|
912
|
+
const {
|
|
913
|
+
asFragment
|
|
914
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
915
|
+
isPopupOpen: true,
|
|
916
|
+
isPopupReady: true,
|
|
917
|
+
palette: "dark"
|
|
918
|
+
})));
|
|
919
|
+
expect(asFragment()).toMatchSnapshot();
|
|
920
|
+
});
|
|
921
|
+
test('Render with isPopupOpen, isPopupReady and isAnimate=false', () => {
|
|
922
|
+
const {
|
|
923
|
+
asFragment
|
|
924
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
925
|
+
isPopupOpen: true,
|
|
926
|
+
isPopupReady: true,
|
|
927
|
+
isAnimate: false
|
|
928
|
+
})));
|
|
929
|
+
expect(asFragment()).toMatchSnapshot();
|
|
930
|
+
});
|
|
931
|
+
test('Render with isPopupOpen, isPopupReady and animationStyle as default', () => {
|
|
932
|
+
const {
|
|
933
|
+
asFragment
|
|
934
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
935
|
+
isPopupOpen: true,
|
|
936
|
+
isPopupReady: true,
|
|
937
|
+
animationStyle: "default"
|
|
938
|
+
})));
|
|
939
|
+
expect(asFragment()).toMatchSnapshot();
|
|
940
|
+
});
|
|
941
|
+
test('Render with isPopupOpen, isPopupReady and isBoxPaddingNeed=false', () => {
|
|
942
|
+
const {
|
|
943
|
+
asFragment
|
|
944
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
945
|
+
isPopupOpen: true,
|
|
946
|
+
isPopupReady: true,
|
|
947
|
+
isBoxPaddingNeed: false
|
|
948
|
+
})));
|
|
949
|
+
expect(asFragment()).toMatchSnapshot();
|
|
950
|
+
});
|
|
951
|
+
test('Render with isPopupOpen, isPopupReady and getFooter', () => {
|
|
952
|
+
const {
|
|
953
|
+
asFragment
|
|
954
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
955
|
+
isPopupOpen: true,
|
|
956
|
+
isPopupReady: true,
|
|
957
|
+
getFooter: () => /*#__PURE__*/React.createElement("span", null, "Footer content")
|
|
958
|
+
})));
|
|
959
|
+
expect(asFragment()).toMatchSnapshot();
|
|
960
|
+
});
|
|
961
|
+
test('Render with isPopupOpen, isPopupReady and dataId', () => {
|
|
962
|
+
const {
|
|
963
|
+
asFragment
|
|
964
|
+
} = render( /*#__PURE__*/React.createElement(MultiSelect, _extends({}, getRequiredProps(), {
|
|
965
|
+
isPopupOpen: true,
|
|
966
|
+
isPopupReady: true,
|
|
967
|
+
dataId: "multi-select-dataId"
|
|
968
|
+
})));
|
|
969
|
+
expect(asFragment()).toMatchSnapshot();
|
|
970
|
+
});
|
|
84
971
|
});
|