@zohodesk/components 1.3.2 → 1.3.3

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 (49) hide show
  1. package/.cli/propValidation_report.html +1 -1
  2. package/README.md +8 -0
  3. package/es/Button/__tests__/Button.spec.js +134 -1
  4. package/es/DateTime/__tests__/YearView.spec.js +1 -2
  5. package/es/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +8 -1
  6. package/es/Provider/IdProvider.js +1 -1
  7. package/es/Select/__tests__/Select.spec.js +1130 -4
  8. package/es/Select/__tests__/__snapshots__/Select.spec.js.snap +9621 -1
  9. package/es/Stencils/Stencils.js +5 -12
  10. package/es/Stencils/Stencils.module.css +11 -7
  11. package/es/Stencils/__tests__/Stencils.spec.js +9 -1
  12. package/es/Stencils/__tests__/__snapshots__/Stencils.spec.js.snap +27 -11
  13. package/es/Stencils/props/defaultProps.js +2 -1
  14. package/es/Stencils/props/propTypes.js +3 -2
  15. package/es/Tab/Tab.js +2 -1
  16. package/es/Tab/TabWrapper.js +2 -1
  17. package/es/Tab/Tabs.js +10 -10
  18. package/es/Tab/__tests__/TabLayout.spec.js +34 -0
  19. package/es/Tab/__tests__/__snapshots__/TabLayout.spec.js.snap +341 -0
  20. package/es/Tab/props/propTypes.js +2 -2
  21. package/es/Tab/utils/tabConfigs.js +18 -0
  22. package/es/Tag/__tests__/Tag.spec.js +8 -1
  23. package/es/utils/Common.js +1 -1
  24. package/lib/Button/__tests__/Button.spec.js +140 -0
  25. package/lib/DateTime/__tests__/YearView.spec.js +1 -2
  26. package/lib/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +8 -0
  27. package/lib/Provider/IdProvider.js +1 -0
  28. package/lib/Select/__tests__/Select.spec.js +1364 -3
  29. package/lib/Select/__tests__/__snapshots__/Select.spec.js.snap +9621 -1
  30. package/lib/Stencils/Stencils.js +5 -12
  31. package/lib/Stencils/Stencils.module.css +11 -7
  32. package/lib/Stencils/__tests__/Stencils.spec.js +11 -3
  33. package/lib/Stencils/__tests__/__snapshots__/Stencils.spec.js.snap +27 -11
  34. package/lib/Stencils/props/defaultProps.js +2 -1
  35. package/lib/Stencils/props/propTypes.js +3 -2
  36. package/lib/Tab/Tab.js +3 -1
  37. package/lib/Tab/TabWrapper.js +3 -1
  38. package/lib/Tab/Tabs.js +11 -10
  39. package/lib/Tab/__tests__/TabLayout.spec.js +41 -0
  40. package/lib/Tab/__tests__/__snapshots__/TabLayout.spec.js.snap +341 -0
  41. package/lib/Tab/props/propTypes.js +2 -2
  42. package/lib/Tab/utils/tabConfigs.js +27 -0
  43. package/lib/Tag/__tests__/Tag.spec.js +10 -2
  44. package/lib/utils/Common.js +1 -1
  45. package/package.json +1 -1
  46. package/react-cli.config.js +2 -2
  47. package/result.json +1 -1
  48. package/es/DateTime/__tests__/__snapshots__/YearView.spec.js.snap +0 -61
  49. package/lib/DateTime/__tests__/__snapshots__/YearView.spec.js.snap +0 -61
@@ -1,12 +1,1138 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react';
2
+ import { render, cleanup, fireEvent, within, waitFor } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import { setGlobalId } from "../../Provider/IdProvider";
3
5
  import Select from "../Select";
4
- describe('Select', () => {
5
- test('rendering the defult props', () => {
6
- const mockOnChange = jest.fn();
6
+ import '@testing-library/jest-dom';
7
+ beforeEach(() => {
8
+ setGlobalId(0);
9
+ });
10
+ afterEach(() => {
11
+ cleanup();
12
+ });
13
+ const selectInputRole = 'Menuitem';
14
+ const dropboxTestId = 'selectComponent_suggestions';
15
+ const listItemRole = 'option';
16
+ const options = [{
17
+ id: '1',
18
+ text: 'Option 1'
19
+ }, {
20
+ id: '2',
21
+ text: 'Option 2'
22
+ }, {
23
+ id: '3',
24
+ text: 'Option 3'
25
+ }];
26
+ const selectOptions = [{
27
+ id: '1',
28
+ text: 'Option 1'
29
+ }, {
30
+ id: '2',
31
+ text: 'Option 2'
32
+ }, {
33
+ id: '3',
34
+ text: 'Option 3'
35
+ }, {
36
+ id: '4',
37
+ text: 'Option 4'
38
+ }, {
39
+ id: '5',
40
+ text: 'Option 5'
41
+ }, {
42
+ id: '6',
43
+ text: 'Option 6'
44
+ }, {
45
+ id: '7',
46
+ text: 'Option 7'
47
+ }, {
48
+ id: '8',
49
+ text: 'Option 8'
50
+ }, {
51
+ id: '9',
52
+ text: 'Option 9'
53
+ }, {
54
+ id: '10',
55
+ text: 'Option 10'
56
+ }];
57
+ describe('Select -', () => {
58
+ test('Should render the Select component', () => {
7
59
  const {
60
+ getByRole,
8
61
  asFragment
9
62
  } = render( /*#__PURE__*/React.createElement(Select, null));
63
+ expect(getByRole(selectInputRole)).toBeInTheDocument();
64
+ expect(asFragment()).toMatchSnapshot();
65
+ });
66
+ test('Should render the placeholder when there is no default value', () => {
67
+ const placeHolder = 'Select Correct Option';
68
+ const {
69
+ getByPlaceholderText,
70
+ asFragment
71
+ } = render( /*#__PURE__*/React.createElement(Select, {
72
+ placeHolder: placeHolder,
73
+ isDefaultSelectValue: false,
74
+ options: options
75
+ }));
76
+ expect(getByPlaceholderText(placeHolder)).toBeInTheDocument();
77
+ expect(asFragment()).toMatchSnapshot();
78
+ });
79
+ test('Should render the default selected value', () => {
80
+ const {
81
+ getByRole,
82
+ asFragment
83
+ } = render( /*#__PURE__*/React.createElement(Select, {
84
+ options: options
85
+ }));
86
+ expect(getByRole(selectInputRole)).toHaveValue('Option 1');
87
+ expect(asFragment()).toMatchSnapshot();
88
+ });
89
+ test('Should render the given selected value', () => {
90
+ const {
91
+ getByRole,
92
+ asFragment
93
+ } = render( /*#__PURE__*/React.createElement(Select, {
94
+ options: options,
95
+ selectedValue: "Option 2"
96
+ }));
97
+ expect(getByRole(selectInputRole)).toHaveValue('Option 2');
98
+ expect(asFragment()).toMatchSnapshot();
99
+ });
100
+ test('Should open the dropdown, when click on the input', () => {
101
+ const {
102
+ getByRole,
103
+ getByTestId,
104
+ asFragment
105
+ } = render( /*#__PURE__*/React.createElement(Select, null));
106
+ userEvent.click(getByRole(selectInputRole));
107
+ expect(getByTestId(dropboxTestId)).toBeInTheDocument();
108
+ expect(asFragment()).toMatchSnapshot();
109
+ });
110
+ test('Should open the dropdown, when press down arrow on the input', () => {
111
+ const {
112
+ getByRole,
113
+ getByTestId
114
+ } = render( /*#__PURE__*/React.createElement(Select, {
115
+ options: options
116
+ }));
117
+ fireEvent.keyDown(getByRole(selectInputRole), {
118
+ key: 'ArrowDown',
119
+ keyCode: 40,
120
+ code: 'ArrowDown'
121
+ });
122
+ expect(getByTestId(dropboxTestId)).toBeInTheDocument();
123
+ });
124
+ test('Should open the dropdown, when isPopupOpenOnEnter is true. If press enter key on the input', () => {
125
+ const {
126
+ getByRole,
127
+ getByTestId
128
+ } = render( /*#__PURE__*/React.createElement(Select, {
129
+ isPopupOpenOnEnter: true,
130
+ options: options
131
+ }));
132
+ fireEvent.keyDown(getByRole(selectInputRole), {
133
+ key: 'Enter',
134
+ keyCode: 13,
135
+ code: 'Enter'
136
+ });
137
+ expect(getByTestId(dropboxTestId)).toBeInTheDocument();
138
+ });
139
+ test('Should open the dropdown, when isPopupOpenOnEnter is true. If press tab key on the input', () => {
140
+ const {
141
+ getByRole,
142
+ getByTestId
143
+ } = render( /*#__PURE__*/React.createElement(Select, {
144
+ isPopupOpenOnEnter: true,
145
+ options: options
146
+ }));
147
+ fireEvent.keyDown(getByRole(selectInputRole), {
148
+ key: 'Tab',
149
+ keyCode: 9,
150
+ code: 'Tab'
151
+ });
152
+ expect(getByTestId(dropboxTestId)).toBeInTheDocument();
153
+ });
154
+ test('Should show the empty message when open the dropdown with no options', () => {
155
+ const emptyMessage = 'No Options Available';
156
+ const {
157
+ getByRole,
158
+ queryByRole,
159
+ getByText,
160
+ asFragment
161
+ } = render( /*#__PURE__*/React.createElement(Select, {
162
+ emptyMessage: emptyMessage
163
+ }));
164
+ userEvent.click(getByRole(selectInputRole));
165
+ expect(queryByRole(listItemRole)).not.toBeInTheDocument();
166
+ expect(getByText(emptyMessage)).toBeInTheDocument();
167
+ expect(asFragment()).toMatchSnapshot();
168
+ });
169
+ test('Should render given the options', () => {
170
+ const {
171
+ getByRole,
172
+ getAllByRole,
173
+ asFragment
174
+ } = render( /*#__PURE__*/React.createElement(Select, {
175
+ options: options
176
+ }));
177
+ userEvent.click(getByRole(selectInputRole));
178
+ expect(getAllByRole(listItemRole)).toHaveLength(3);
179
+ expect(getAllByRole(listItemRole)[0]).toHaveTextContent('Option 1');
180
+ expect(getAllByRole(listItemRole)[1]).toHaveTextContent('Option 2');
181
+ expect(getAllByRole(listItemRole)[2]).toHaveTextContent('Option 3');
182
+ expect(asFragment()).toMatchSnapshot();
183
+ });
184
+ test('Should trigger the onChange event when select an option', () => {
185
+ const mockOnChange = jest.fn();
186
+ const {
187
+ getByRole,
188
+ getAllByRole
189
+ } = render( /*#__PURE__*/React.createElement(Select, {
190
+ options: options,
191
+ onChange: mockOnChange
192
+ }));
193
+ userEvent.click(getByRole(selectInputRole));
194
+ userEvent.click(getAllByRole(listItemRole)[1]);
195
+ expect(mockOnChange).toHaveBeenCalledWith('2', {
196
+ groupId: '',
197
+ id: '2',
198
+ text: 'Option 2'
199
+ });
200
+ });
201
+ test('Should update the value when select the option', () => {
202
+ const {
203
+ getByRole,
204
+ getAllByRole,
205
+ rerender,
206
+ asFragment
207
+ } = render( /*#__PURE__*/React.createElement(Select, {
208
+ options: options
209
+ }));
210
+ const inputElement = getByRole(selectInputRole);
211
+ expect(inputElement).toHaveValue('Option 1');
212
+ userEvent.click(inputElement);
213
+ expect(asFragment()).toMatchSnapshot();
214
+ userEvent.click(getAllByRole(listItemRole)[1]);
215
+ rerender( /*#__PURE__*/React.createElement(Select, {
216
+ options: options,
217
+ selectedValue: "Option 2"
218
+ }));
219
+ expect(asFragment()).toMatchSnapshot();
220
+ expect(inputElement).toHaveValue('Option 2');
221
+ });
222
+ test('Should focus the search input, when open the dropdown', async () => {
223
+ const {
224
+ getByRole,
225
+ getByTestId
226
+ } = render( /*#__PURE__*/React.createElement(Select, {
227
+ needSearch: true,
228
+ options: options
229
+ }));
230
+ userEvent.click(getByRole(selectInputRole));
231
+ await waitFor(() => {
232
+ expect(within(getByTestId(dropboxTestId)).getByRole('textbox')).toHaveFocus();
233
+ });
234
+ });
235
+ test('Should render the only options matching search value', () => {
236
+ const {
237
+ getByRole,
238
+ getAllByRole,
239
+ asFragment,
240
+ getByTestId
241
+ } = render( /*#__PURE__*/React.createElement(Select, {
242
+ needSearch: true,
243
+ options: options
244
+ }));
245
+ userEvent.click(getByRole(selectInputRole));
246
+ userEvent.type(within(getByTestId(dropboxTestId)).getByRole('textbox'), '2');
247
+ expect(getAllByRole(listItemRole)).toHaveLength(1);
248
+ expect(asFragment()).toMatchSnapshot();
249
+ });
250
+ test('Should trigger given onSearch, when type on the search input', async () => {
251
+ const mockOnSearch = jest.fn();
252
+ const {
253
+ getByRole,
254
+ getByTestId
255
+ } = render( /*#__PURE__*/React.createElement(Select, {
256
+ needSearch: true,
257
+ options: options,
258
+ onSearch: mockOnSearch
259
+ }));
260
+ userEvent.click(getByRole(selectInputRole));
261
+ userEvent.type(within(getByTestId(dropboxTestId)).getByRole('textbox'), '2');
262
+ await waitFor(() => {
263
+ expect(mockOnSearch).toHaveBeenCalledWith('2');
264
+ });
265
+ });
266
+ test('Should render all the options when search value is cleared', () => {
267
+ const {
268
+ getByRole,
269
+ getAllByRole,
270
+ asFragment,
271
+ getByTestId
272
+ } = render( /*#__PURE__*/React.createElement(Select, {
273
+ needSearch: true,
274
+ options: options
275
+ }));
276
+ userEvent.click(getByRole(selectInputRole));
277
+ const searchInput = within(getByTestId(dropboxTestId)).getByRole('textbox');
278
+ userEvent.type(searchInput, 'option 2');
279
+ expect(getAllByRole(listItemRole)).toHaveLength(1);
280
+ userEvent.click(within(getByTestId('CardHeader')).getByRole('button'));
281
+ expect(getAllByRole(listItemRole)).toHaveLength(3);
282
+ expect(searchInput).toHaveValue('');
283
+ expect(searchInput).toHaveFocus();
284
+ expect(asFragment()).toMatchSnapshot();
285
+ });
286
+ test('Should not open the dropdown when disabled', () => {
287
+ const {
288
+ getByRole,
289
+ queryByTestId,
290
+ asFragment
291
+ } = render( /*#__PURE__*/React.createElement(Select, {
292
+ options: options,
293
+ isDisabled: true
294
+ }));
295
+ userEvent.click(getByRole(selectInputRole));
296
+ expect(queryByTestId(dropboxTestId)).not.toBeInTheDocument();
297
+ expect(asFragment()).toMatchSnapshot();
298
+ });
299
+ test('Should not open the dropdown when readonly', () => {
300
+ const {
301
+ getByRole,
302
+ queryByTestId,
303
+ asFragment
304
+ } = render( /*#__PURE__*/React.createElement(Select, {
305
+ options: options,
306
+ isReadOnly: true
307
+ }));
308
+ userEvent.click(getByRole(selectInputRole));
309
+ expect(queryByTestId(dropboxTestId)).not.toBeInTheDocument();
310
+ expect(asFragment()).toMatchSnapshot();
311
+ });
312
+ test('Should close the dropdown when clicking outside', () => {
313
+ const {
314
+ getByRole,
315
+ queryByTestId,
316
+ asFragment
317
+ } = render( /*#__PURE__*/React.createElement(Select, {
318
+ options: options
319
+ }));
320
+ userEvent.click(getByRole(selectInputRole));
321
+ expect(queryByTestId(dropboxTestId)).toBeInTheDocument();
322
+ userEvent.click(document.body);
323
+ expect(queryByTestId(dropboxTestId)).not.toBeInTheDocument();
324
+ expect(asFragment()).toMatchSnapshot();
325
+ });
326
+ test('Should show the custom empty state using getCustomEmptyState prop, when there is no matching options search value', () => {
327
+ const emptyMessage = 'Custom Empty State';
328
+ const getCustomEmptyState = jest.fn(() => /*#__PURE__*/React.createElement("div", null, emptyMessage));
329
+ const {
330
+ getByText,
331
+ getByRole,
332
+ asFragment,
333
+ getByTestId
334
+ } = render( /*#__PURE__*/React.createElement(Select, {
335
+ needSearch: true,
336
+ options: options,
337
+ getCustomEmptyState: getCustomEmptyState
338
+ }));
339
+ userEvent.click(getByRole(selectInputRole));
340
+ userEvent.type(within(getByTestId(dropboxTestId)).getByRole('textbox'), '5');
341
+ expect(getByText(emptyMessage)).toBeInTheDocument();
342
+ expect(asFragment()).toMatchSnapshot();
343
+ });
344
+ test('Should call the onKeyDown function, when press any key in the input element', () => {
345
+ const mockKeyDown = jest.fn();
346
+ const {
347
+ getByRole
348
+ } = render( /*#__PURE__*/React.createElement(Select, {
349
+ onKeyDown: mockKeyDown
350
+ }));
351
+ fireEvent.keyDown(getByRole(selectInputRole), {
352
+ key: 'a',
353
+ code: 'KeyA'
354
+ });
355
+ expect(mockKeyDown).toHaveBeenCalled();
356
+ });
357
+ test('Should highlight the next list-items, when arrow keys pressed', () => {
358
+ const {
359
+ getByRole,
360
+ getAllByRole,
361
+ asFragment
362
+ } = render( /*#__PURE__*/React.createElement(Select, {
363
+ options: options
364
+ }));
365
+ userEvent.click(getByRole(selectInputRole));
366
+ const listItems = getAllByRole(listItemRole);
367
+ expect(listItems[0]).toHaveAttribute("data-a11y-list-active", "true");
368
+ userEvent.keyboard('{arrowdown}');
369
+ expect(listItems[0]).toHaveAttribute("data-a11y-list-active", "false");
370
+ expect(listItems[1]).toHaveAttribute("data-a11y-list-active", "true");
371
+ userEvent.keyboard('{arrowdown}');
372
+ expect(listItems[1]).toHaveAttribute("data-a11y-list-active", "false");
373
+ expect(listItems[2]).toHaveAttribute("data-a11y-list-active", "true");
374
+ userEvent.keyboard('{arrowdown}');
375
+ expect(listItems[2]).toHaveAttribute("data-a11y-list-active", "true");
376
+ userEvent.keyboard('{arrowup}');
377
+ expect(listItems[2]).toHaveAttribute("data-a11y-list-active", "false");
378
+ expect(listItems[1]).toHaveAttribute("data-a11y-list-active", "true");
379
+ expect(asFragment()).toMatchSnapshot();
380
+ userEvent.keyboard('{arrowup}');
381
+ expect(listItems[1]).toHaveAttribute("data-a11y-list-active", "false");
382
+ expect(listItems[0]).toHaveAttribute("data-a11y-list-active", "true");
383
+ userEvent.keyboard('{arrowup}');
384
+ expect(listItems[0]).toHaveAttribute("data-a11y-list-active", "true");
385
+ });
386
+ test('Should update the value, when select the option using keyboard', () => {
387
+ const mockOnChange = jest.fn();
388
+ const {
389
+ getByRole,
390
+ asFragment
391
+ } = render( /*#__PURE__*/React.createElement(Select, {
392
+ options: options,
393
+ onChange: mockOnChange
394
+ }));
395
+ userEvent.click(getByRole(selectInputRole));
396
+ userEvent.keyboard('{arrowdown}');
397
+ userEvent.keyboard('{enter}');
398
+ expect(mockOnChange).toHaveBeenCalledWith('2', {
399
+ groupId: '',
400
+ id: '2',
401
+ text: 'Option 2'
402
+ });
403
+ expect(asFragment()).toMatchSnapshot();
404
+ });
405
+ test('Should close the dropdown and focus the select input, when press escape key', async () => {
406
+ const {
407
+ getByRole,
408
+ getByTestId,
409
+ queryByTestId
410
+ } = render( /*#__PURE__*/React.createElement(Select, {
411
+ needSearch: true,
412
+ options: options
413
+ }));
414
+ userEvent.click(getByRole(selectInputRole));
415
+ expect(queryByTestId(dropboxTestId)).toBeInTheDocument();
416
+ await waitFor(() => {
417
+ expect(within(getByTestId(dropboxTestId)).getByRole('textbox')).toHaveFocus();
418
+ });
419
+ userEvent.keyboard('{escape}');
420
+ await waitFor(() => {
421
+ expect(queryByTestId(dropboxTestId)).not.toBeInTheDocument();
422
+ expect(getByRole(selectInputRole)).toHaveFocus();
423
+ });
424
+ });
425
+ test('Should close the dropdown and trigger the onchange, when press tab key', async () => {
426
+ const mockOnChange = jest.fn();
427
+ const {
428
+ getByRole,
429
+ getByTestId,
430
+ queryByTestId
431
+ } = render( /*#__PURE__*/React.createElement(Select, {
432
+ needSearch: true,
433
+ options: options,
434
+ onChange: mockOnChange
435
+ }));
436
+ userEvent.click(getByRole(selectInputRole));
437
+ await waitFor(() => {
438
+ expect(within(getByTestId(dropboxTestId)).getByRole('textbox')).toHaveFocus();
439
+ });
440
+ fireEvent.keyDown(within(getByTestId(dropboxTestId)).getByRole('textbox'), {
441
+ key: 'ArrowDown',
442
+ code: 'ArrowDown',
443
+ keyCode: 40
444
+ });
445
+ fireEvent.keyDown(within(getByTestId(dropboxTestId)).getByRole('textbox'), {
446
+ key: 'Tab',
447
+ code: 'Tab',
448
+ keyCode: 9
449
+ });
450
+ await waitFor(() => {
451
+ expect(mockOnChange).toHaveBeenCalledWith('2', {
452
+ groupId: '',
453
+ id: '2',
454
+ text: 'Option 2'
455
+ });
456
+ expect(queryByTestId(dropboxTestId)).not.toBeInTheDocument();
457
+ expect(getByRole(selectInputRole)).toHaveFocus();
458
+ });
459
+ });
460
+ test('Should trigger getNextOptions, when scroll to the end of the dropbox list and isNextOptions is true', async () => {
461
+ const mockGetNextOptions = jest.fn(() => {
462
+ return new Promise(resolve => {
463
+ setTimeout(() => {
464
+ resolve();
465
+ }, 2000);
466
+ });
467
+ });
468
+ const {
469
+ getByRole,
470
+ getByTestId,
471
+ asFragment
472
+ } = render( /*#__PURE__*/React.createElement(Select, {
473
+ options: selectOptions,
474
+ isNextOptions: true,
475
+ getNextOptions: mockGetNextOptions
476
+ }));
477
+ userEvent.click(getByRole(selectInputRole));
478
+ const cardContent = within(getByTestId(dropboxTestId)).getByTestId('CardContent');
479
+ Object.defineProperty(cardContent, 'scrollHeight', {
480
+ value: 1000,
481
+ writable: true
482
+ });
483
+ Object.defineProperty(cardContent, 'clientHeight', {
484
+ value: 800,
485
+ writable: true
486
+ });
487
+ Object.defineProperty(cardContent, 'offsetHeight', {
488
+ value: 800,
489
+ writable: true
490
+ });
491
+ fireEvent.scroll(cardContent, {
492
+ target: {
493
+ scrollTop: 201
494
+ }
495
+ });
496
+ await waitFor(() => {
497
+ const loader = within(getByTestId(dropboxTestId)).queryByTestId('loader');
498
+ expect(loader).toBeInTheDocument();
499
+ expect(asFragment()).toMatchSnapshot();
500
+ expect(mockGetNextOptions).toHaveBeenCalledWith('');
501
+ });
502
+ await waitFor(() => {
503
+ const loader = within(getByTestId(dropboxTestId)).queryByTestId('loader');
504
+ expect(loader).not.toBeInTheDocument();
505
+ }, {
506
+ timeout: 2500
507
+ });
508
+ });
509
+ test('Should trigger getNextOptions, when search with needLocalSearch is false', async () => {
510
+ const mockGetNextOptions = jest.fn(() => {
511
+ return new Promise((resolve, reject) => {
512
+ setTimeout(() => {
513
+ reject();
514
+ }, 2000);
515
+ });
516
+ });
517
+ const {
518
+ getByRole,
519
+ getByTestId,
520
+ asFragment
521
+ } = render( /*#__PURE__*/React.createElement(Select, {
522
+ needSearch: true,
523
+ needLocalSearch: false,
524
+ options: options,
525
+ isNextOptions: true,
526
+ getNextOptions: mockGetNextOptions
527
+ }));
528
+ userEvent.click(getByRole(selectInputRole));
529
+ userEvent.type(within(getByTestId(dropboxTestId)).getByRole('textbox'), 'a');
530
+ const loader = within(getByTestId(dropboxTestId)).queryByTestId('loader');
531
+ await waitFor(() => {
532
+ expect(loader).toBeInTheDocument();
533
+ expect(asFragment()).toMatchSnapshot();
534
+ expect(mockGetNextOptions).toHaveBeenCalledWith('');
535
+ });
536
+ await waitFor(() => {
537
+ expect(loader).not.toBeInTheDocument();
538
+ }, {
539
+ timeout: 2500
540
+ });
541
+ });
542
+ test('Should trigger onChange, when type on select input with autoSelectOnType is true', async () => {
543
+ const mockOnChange = jest.fn();
544
+ const optionsList = [{
545
+ id: '1',
546
+ text: 'Madurai'
547
+ }, {
548
+ id: '2',
549
+ text: 'Chennai'
550
+ }, {
551
+ id: '3',
552
+ text: 'Coimbatore'
553
+ }, {
554
+ id: '4',
555
+ text: 'Trichy'
556
+ }];
557
+ const {
558
+ getByRole
559
+ } = render( /*#__PURE__*/React.createElement(Select, {
560
+ options: optionsList,
561
+ autoSelectOnType: true,
562
+ onChange: mockOnChange
563
+ }));
564
+ fireEvent.keyPress(getByRole(selectInputRole), {
565
+ key: 'c',
566
+ code: 'KeyC',
567
+ keyCode: 67,
568
+ charCode: 67
569
+ });
570
+ await waitFor(() => {
571
+ expect(mockOnChange).toHaveBeenCalledWith('2', {
572
+ groupId: '',
573
+ id: '2',
574
+ text: 'Chennai'
575
+ });
576
+ });
577
+ fireEvent.keyPress(getByRole(selectInputRole), {
578
+ key: 'c',
579
+ code: 'KeyC',
580
+ keyCode: 67,
581
+ charCode: 67
582
+ });
583
+ await waitFor(() => {
584
+ expect(mockOnChange).toHaveBeenCalledWith('3', {
585
+ groupId: '',
586
+ id: '3',
587
+ text: 'Coimbatore'
588
+ });
589
+ });
590
+ fireEvent.keyPress(getByRole(selectInputRole), {
591
+ key: 'c',
592
+ code: 'KeyC',
593
+ keyCode: 67,
594
+ charCode: 67
595
+ });
596
+ await waitFor(() => {
597
+ expect(mockOnChange).toHaveBeenCalledWith('2', {
598
+ groupId: '',
599
+ id: '2',
600
+ text: 'Chennai'
601
+ });
602
+ });
603
+ });
604
+ test('Should trigger onAddNewOption, when click on the custom search empty state button', () => {
605
+ const addMessage = 'Add New Option';
606
+ const getCustomEmptyState = jest.fn(_ref => {
607
+ let {
608
+ searchString,
609
+ onAddNewOption
610
+ } = _ref;
611
+ return /*#__PURE__*/React.createElement("button", {
612
+ onClick: onAddNewOption
613
+ }, addMessage);
614
+ });
615
+ const mockOnAddNewOption = jest.fn();
616
+ const {
617
+ getByRole,
618
+ getByTestId,
619
+ asFragment
620
+ } = render( /*#__PURE__*/React.createElement(Select, {
621
+ needSearch: true,
622
+ options: options,
623
+ onAddNewOption: mockOnAddNewOption,
624
+ getCustomEmptyState: getCustomEmptyState
625
+ }));
626
+ userEvent.click(getByRole(selectInputRole));
627
+ userEvent.type(within(getByTestId(dropboxTestId)).getByRole('textbox'), '5');
628
+ expect(getCustomEmptyState).toHaveBeenCalledWith({
629
+ searchString: '5',
630
+ onAddNewOption: expect.any(Function)
631
+ });
632
+ expect(getByRole('button', {
633
+ name: addMessage
634
+ })).toBeInTheDocument();
635
+ expect(asFragment()).toMatchSnapshot();
636
+ userEvent.click(getByRole('button', {
637
+ name: addMessage
638
+ }));
639
+ expect(mockOnAddNewOption).toHaveBeenCalledWith('5');
640
+ }); // Yellow coverage
641
+
642
+ test('Should trigger the onDropBoxOpen, when open the select', () => {
643
+ const mockOnDropBoxOpen = jest.fn();
644
+ const {
645
+ getByRole
646
+ } = render( /*#__PURE__*/React.createElement(Select, {
647
+ options: options,
648
+ onDropBoxOpen: mockOnDropBoxOpen
649
+ }));
650
+ userEvent.click(getByRole(selectInputRole));
651
+ expect(mockOnDropBoxOpen).toHaveBeenCalledWith('');
652
+ });
653
+ test('Should trigger the onDropBoxClose, when close the select', () => {
654
+ const mockOnDropBoxClose = jest.fn();
655
+ const {
656
+ getByRole
657
+ } = render( /*#__PURE__*/React.createElement(Select, {
658
+ options: options,
659
+ onDropBoxClose: mockOnDropBoxClose
660
+ }));
661
+ userEvent.click(getByRole(selectInputRole));
662
+ userEvent.click(document.body);
663
+ expect(mockOnDropBoxClose).toHaveBeenCalledWith();
664
+ });
665
+ test('Should trigger the onSearch with empty string, when close the select and isSearchClearOnClose is true', async () => {
666
+ const mockOnSearch = jest.fn();
667
+ const {
668
+ getByRole,
669
+ getByTestId
670
+ } = render( /*#__PURE__*/React.createElement(Select, {
671
+ needSearch: true,
672
+ isSearchClearOnClose: true,
673
+ options: options,
674
+ onSearch: mockOnSearch
675
+ }));
676
+ userEvent.click(getByRole(selectInputRole));
677
+ userEvent.type(within(getByTestId(dropboxTestId)).getByRole('textbox'), '2');
678
+ await waitFor(() => {
679
+ expect(mockOnSearch).toHaveBeenCalledWith('2');
680
+ });
681
+ userEvent.click(document.body);
682
+ await waitFor(() => {
683
+ expect(mockOnSearch).toHaveBeenCalledWith('');
684
+ });
685
+ });
686
+ test('Should trigger the onSearch with search string, when close the select and isSearchClearOnClose is false', async () => {
687
+ const mockOnSearch = jest.fn();
688
+ const {
689
+ getByRole,
690
+ getByTestId
691
+ } = render( /*#__PURE__*/React.createElement(Select, {
692
+ needSearch: true,
693
+ isSearchClearOnClose: false,
694
+ options: options,
695
+ onSearch: mockOnSearch
696
+ }));
697
+ userEvent.click(getByRole(selectInputRole));
698
+ userEvent.type(within(getByTestId(dropboxTestId)).getByRole('textbox'), '2');
699
+ await waitFor(() => {
700
+ expect(mockOnSearch).toHaveBeenCalledWith('2');
701
+ });
702
+ userEvent.click(document.body);
703
+ await waitFor(() => {
704
+ expect(mockOnSearch).toHaveBeenCalledWith('2');
705
+ });
706
+ });
707
+ test('Should trigger the getPopupHandlers with popup handlers, when select is mounted', () => {
708
+ const mockGetPopupHandlers = jest.fn();
709
+ render( /*#__PURE__*/React.createElement(Select, {
710
+ options: options,
711
+ getPopupHandlers: mockGetPopupHandlers
712
+ }));
713
+ expect(mockGetPopupHandlers).toHaveBeenCalledWith({
714
+ removeClose: expect.any(Function),
715
+ openPopup: expect.any(Function),
716
+ closePopup: expect.any(Function),
717
+ togglePopup: expect.any(Function)
718
+ });
719
+ });
720
+ test('Should trigger the getPopupHandlers with null, when select is unmounted', () => {
721
+ const mockGetPopupHandlers = jest.fn();
722
+ const {
723
+ unmount
724
+ } = render( /*#__PURE__*/React.createElement(Select, {
725
+ options: options,
726
+ getPopupHandlers: mockGetPopupHandlers
727
+ }));
728
+ unmount();
729
+ expect(mockGetPopupHandlers).toHaveBeenCalledWith({
730
+ removeClose: null,
731
+ openPopup: null,
732
+ closePopup: null,
733
+ togglePopup: null
734
+ });
735
+ });
736
+ test('Should trigger the togglePopup with given defaultDropBoxPosition', () => {
737
+ const {
738
+ getByRole,
739
+ getByTestId
740
+ } = render( /*#__PURE__*/React.createElement(Select, {
741
+ options: options,
742
+ defaultDropBoxPosition: "topCenter"
743
+ }));
744
+ userEvent.click(getByRole(selectInputRole));
745
+ expect(getByTestId(dropboxTestId)).toHaveAttribute('data-position', 'topMid');
746
+ });
747
+ test('Should trigger the onFocus, when open the select', () => {
748
+ const mockOnFocus = jest.fn();
749
+ const {
750
+ getByRole
751
+ } = render( /*#__PURE__*/React.createElement(Select, {
752
+ options: options,
753
+ onFocus: mockOnFocus
754
+ }));
755
+ userEvent.click(getByRole(selectInputRole));
756
+ expect(mockOnFocus).toHaveBeenCalledWith(expect.any(Object));
757
+ });
758
+ test('Should trigger the getPopupHandlers with popup handlers, when select is mounted', () => {
759
+ const mockGetRef = jest.fn();
760
+ const {
761
+ getByRole
762
+ } = render( /*#__PURE__*/React.createElement(Select, {
763
+ options: options,
764
+ getRef: mockGetRef
765
+ }));
766
+ expect(mockGetRef).toHaveBeenCalledWith(getByRole(selectInputRole));
767
+ });
768
+ test('Should not open the dropdown, when press down arrow on the input with needSelectDownIcon as false', () => {
769
+ const {
770
+ getByRole,
771
+ queryByTestId
772
+ } = render( /*#__PURE__*/React.createElement(Select, {
773
+ options: options,
774
+ needSelectDownIcon: false
775
+ }));
776
+ fireEvent.keyDown(getByRole(selectInputRole), {
777
+ key: 'ArrowDown',
778
+ keyCode: 40,
779
+ code: 'ArrowDown'
780
+ });
781
+ expect(queryByTestId(dropboxTestId)).not.toBeInTheDocument();
782
+ });
783
+ test('Should open the dropdown, when press down arrow on the input with getChildren used and needSelectDownIcon as false', () => {
784
+ const {
785
+ getByRole,
786
+ getByTestId
787
+ } = render( /*#__PURE__*/React.createElement(Select, {
788
+ options: options,
789
+ needSelectDownIcon: false,
790
+ getChildren: () => /*#__PURE__*/React.createElement("span", null, "getChildren element")
791
+ }));
792
+ fireEvent.keyDown(getByRole(selectInputRole), {
793
+ key: 'ArrowDown',
794
+ keyCode: 40,
795
+ code: 'ArrowDown'
796
+ });
797
+ expect(getByTestId(dropboxTestId)).toBeInTheDocument();
798
+ });
799
+ });
800
+ describe('Select snapshot - ', () => {
801
+ test('Should render with isParentBased as false', () => {
802
+ const {
803
+ asFragment
804
+ } = render( /*#__PURE__*/React.createElement(Select, {
805
+ isParentBased: false
806
+ }));
807
+ expect(asFragment()).toMatchSnapshot();
808
+ });
809
+ const sizes = ['small', 'medium'];
810
+ test.each(sizes)('Should render with size as %s', size => {
811
+ const {
812
+ asFragment
813
+ } = render( /*#__PURE__*/React.createElement(Select, {
814
+ size: size
815
+ }));
816
+ expect(asFragment()).toMatchSnapshot();
817
+ });
818
+ test('Should render with iconOnHover as true', () => {
819
+ const {
820
+ asFragment
821
+ } = render( /*#__PURE__*/React.createElement(Select, {
822
+ iconOnHover: true
823
+ }));
824
+ expect(asFragment()).toMatchSnapshot();
825
+ });
826
+ test('Should render with iconOnHover as true and isReadOnly as true', () => {
827
+ const {
828
+ asFragment
829
+ } = render( /*#__PURE__*/React.createElement(Select, {
830
+ iconOnHover: true,
831
+ isReadOnly: true
832
+ }));
833
+ expect(asFragment()).toMatchSnapshot();
834
+ });
835
+ test('Should render with iconOnHover as true and isDisabled as true', () => {
836
+ const {
837
+ asFragment
838
+ } = render( /*#__PURE__*/React.createElement(Select, {
839
+ iconOnHover: true,
840
+ isDisabled: true
841
+ }));
842
+ expect(asFragment()).toMatchSnapshot();
843
+ });
844
+ test('Should render with title prop', () => {
845
+ const {
846
+ asFragment
847
+ } = render( /*#__PURE__*/React.createElement(Select, {
848
+ title: "Select tooltip"
849
+ }));
850
+ expect(asFragment()).toMatchSnapshot();
851
+ });
852
+ test('Should render with dataSelectorId prop', () => {
853
+ const {
854
+ asFragment
855
+ } = render( /*#__PURE__*/React.createElement(Select, {
856
+ dataSelectorId: "customSelectorId"
857
+ }));
858
+ expect(asFragment()).toMatchSnapshot();
859
+ });
860
+ test('Should render with className prop', () => {
861
+ const {
862
+ asFragment
863
+ } = render( /*#__PURE__*/React.createElement(Select, {
864
+ className: "customClass"
865
+ }));
866
+ expect(asFragment()).toMatchSnapshot();
867
+ });
868
+ test('Should render with needSelectDownIcon as false', () => {
869
+ const {
870
+ asFragment
871
+ } = render( /*#__PURE__*/React.createElement(Select, {
872
+ needSelectDownIcon: false
873
+ }));
874
+ expect(asFragment()).toMatchSnapshot();
875
+ });
876
+ test('Should render with isLoading', () => {
877
+ const {
878
+ asFragment
879
+ } = render( /*#__PURE__*/React.createElement(Select, {
880
+ isPopupOpen: true,
881
+ isLoading: true
882
+ }));
883
+ expect(asFragment()).toMatchSnapshot();
884
+ });
885
+ test('Should render with children', () => {
886
+ const {
887
+ asFragment
888
+ } = render( /*#__PURE__*/React.createElement(Select, null, /*#__PURE__*/React.createElement("span", null, "children element")));
889
+ expect(asFragment()).toMatchSnapshot();
890
+ });
891
+ test('Should render with children and dropdown open', () => {
892
+ const {
893
+ asFragment
894
+ } = render( /*#__PURE__*/React.createElement(Select, {
895
+ isPopupOpen: true
896
+ }, /*#__PURE__*/React.createElement("span", null, "children element")));
897
+ expect(asFragment()).toMatchSnapshot();
898
+ });
899
+ const dropBoxSizes = ['small', 'medium', 'large'];
900
+ test.each(dropBoxSizes)('Should render with dropBoxSize as %s', dropBoxSize => {
901
+ const {
902
+ asFragment
903
+ } = render( /*#__PURE__*/React.createElement(Select, {
904
+ isPopupOpen: true,
905
+ dropBoxSize: dropBoxSize,
906
+ needSearch: true
907
+ }));
908
+ expect(asFragment()).toMatchSnapshot();
909
+ });
910
+ test('Should render with getFooter', () => {
911
+ const {
912
+ asFragment
913
+ } = render( /*#__PURE__*/React.createElement(Select, {
914
+ isPopupOpen: true,
915
+ getFooter: () => /*#__PURE__*/React.createElement("span", null, "getFooter element")
916
+ }));
917
+ expect(asFragment()).toMatchSnapshot();
918
+ });
919
+ test('Should render with getChildren', () => {
920
+ const {
921
+ asFragment
922
+ } = render( /*#__PURE__*/React.createElement(Select, {
923
+ isPopupOpen: true,
924
+ getChildren: () => /*#__PURE__*/React.createElement("span", null, "getChildren element")
925
+ }));
926
+ expect(asFragment()).toMatchSnapshot();
927
+ });
928
+ test(`Should render with customProps`, () => {
929
+ const {
930
+ asFragment
931
+ } = render( /*#__PURE__*/React.createElement(Select, {
932
+ needSearch: true,
933
+ options: options,
934
+ isPopupOpen: true,
935
+ customProps: {
936
+ TextBoxProps: {
937
+ 'data-custom-attr': 'true'
938
+ },
939
+ DropdownSearchTextBoxProps: {
940
+ 'data-custom-search-attr': 'true'
941
+ },
942
+ SuggestionsProps: {
943
+ listItemSize: 'small'
944
+ },
945
+ TextBoxIconProps: {
946
+ 'data-custom-select-attr': 'true'
947
+ },
948
+ listItemProps: {
949
+ 'data-custom-listitem-attr': 'true'
950
+ }
951
+ }
952
+ }));
953
+ expect(asFragment()).toMatchSnapshot();
954
+ });
955
+ });
956
+ describe('Select box needSelectDownIcon snapshot - ', () => {
957
+ [true, false].forEach(needSelectDownIcon => {
958
+ test(`Should render with aria properties - needSelectDownIcon as ${needSelectDownIcon}`, () => {
959
+ const {
960
+ asFragment
961
+ } = render( /*#__PURE__*/React.createElement(Select, {
962
+ i18nKeys: {
963
+ TextBox_ally_label: ''
964
+ },
965
+ ariaLabelledby: "customLabelId",
966
+ options: options,
967
+ needSelectDownIcon: needSelectDownIcon
968
+ }));
969
+ expect(asFragment()).toMatchSnapshot();
970
+ });
971
+ test(`Should render with isPopupOpen as true - needSelectDownIcon as ${needSelectDownIcon}`, () => {
972
+ const {
973
+ asFragment
974
+ } = render( /*#__PURE__*/React.createElement(Select, {
975
+ isPopupOpen: true,
976
+ needSelectDownIcon: needSelectDownIcon
977
+ }));
978
+ expect(asFragment()).toMatchSnapshot();
979
+ });
980
+ test(`Should render with maxLength - needSelectDownIcon as ${needSelectDownIcon}`, () => {
981
+ const {
982
+ asFragment
983
+ } = render( /*#__PURE__*/React.createElement(Select, {
984
+ maxLength: "100",
985
+ needSelectDownIcon: needSelectDownIcon
986
+ }));
987
+ expect(asFragment()).toMatchSnapshot();
988
+ });
989
+ test(`Should render with needBorder as false - needSelectDownIcon as ${needSelectDownIcon}`, () => {
990
+ const {
991
+ asFragment
992
+ } = render( /*#__PURE__*/React.createElement(Select, {
993
+ needBorder: false,
994
+ needSelectDownIcon: needSelectDownIcon
995
+ }));
996
+ expect(asFragment()).toMatchSnapshot();
997
+ });
998
+ test(`Should render with placeHolder - needSelectDownIcon as ${needSelectDownIcon}`, () => {
999
+ const {
1000
+ asFragment
1001
+ } = render( /*#__PURE__*/React.createElement(Select, {
1002
+ placeHolder: "custom placeholder",
1003
+ needSelectDownIcon: needSelectDownIcon
1004
+ }));
1005
+ expect(asFragment()).toMatchSnapshot();
1006
+ });
1007
+ test(`Should render with isReadOnly as true - needSelectDownIcon as ${needSelectDownIcon}`, () => {
1008
+ const {
1009
+ asFragment
1010
+ } = render( /*#__PURE__*/React.createElement(Select, {
1011
+ isReadOnly: true,
1012
+ needSelectDownIcon: needSelectDownIcon
1013
+ }));
1014
+ expect(asFragment()).toMatchSnapshot();
1015
+ });
1016
+ test(`Should render with isDisabled as true - needSelectDownIcon as ${needSelectDownIcon}`, () => {
1017
+ const {
1018
+ asFragment
1019
+ } = render( /*#__PURE__*/React.createElement(Select, {
1020
+ isDisabled: true,
1021
+ needSelectDownIcon: needSelectDownIcon
1022
+ }));
1023
+ expect(asFragment()).toMatchSnapshot();
1024
+ });
1025
+ const textBoxSizes = ['xsmall', 'small', 'medium', 'xmedium'];
1026
+ test.each(textBoxSizes)(`Should render with textBoxSize as %s - needSelectDownIcon as ${needSelectDownIcon}`, textBoxSize => {
1027
+ const {
1028
+ asFragment
1029
+ } = render( /*#__PURE__*/React.createElement(Select, {
1030
+ textBoxSize: textBoxSize,
1031
+ needSelectDownIcon: needSelectDownIcon
1032
+ }));
1033
+ expect(asFragment()).toMatchSnapshot();
1034
+ });
1035
+ const textBoxVariants = ['primary', 'secondary', 'default', 'light'];
1036
+ test.each(textBoxVariants)(`Should render with textBoxVariant as %s - needSelectDownIcon as ${needSelectDownIcon}`, textBoxVariant => {
1037
+ const {
1038
+ asFragment
1039
+ } = render( /*#__PURE__*/React.createElement(Select, {
1040
+ textBoxVariant: textBoxVariant,
1041
+ needSelectDownIcon: needSelectDownIcon
1042
+ }));
1043
+ expect(asFragment()).toMatchSnapshot();
1044
+ });
1045
+ const borderColors = ['transparent', 'default'];
1046
+ test.each(borderColors)(`Should render with borderColor as %s - needSelectDownIcon as ${needSelectDownIcon}`, borderColor => {
1047
+ const {
1048
+ asFragment
1049
+ } = render( /*#__PURE__*/React.createElement(Select, {
1050
+ borderColor: borderColor,
1051
+ needSelectDownIcon: needSelectDownIcon
1052
+ }));
1053
+ expect(asFragment()).toMatchSnapshot();
1054
+ });
1055
+ test(`Should render with htmlId - needSelectDownIcon as ${needSelectDownIcon}`, () => {
1056
+ const {
1057
+ asFragment
1058
+ } = render( /*#__PURE__*/React.createElement(Select, {
1059
+ htmlId: "customHtmlId",
1060
+ needSelectDownIcon: needSelectDownIcon
1061
+ }));
1062
+ expect(asFragment()).toMatchSnapshot();
1063
+ });
1064
+ test(`Should render with autoComplete as true - needSelectDownIcon as ${needSelectDownIcon}`, () => {
1065
+ const {
1066
+ asFragment
1067
+ } = render( /*#__PURE__*/React.createElement(Select, {
1068
+ autoComplete: true,
1069
+ needSelectDownIcon: needSelectDownIcon
1070
+ }));
1071
+ expect(asFragment()).toMatchSnapshot();
1072
+ });
1073
+ test(`Should render with title - needSelectDownIcon as ${needSelectDownIcon}`, () => {
1074
+ const {
1075
+ asFragment
1076
+ } = render( /*#__PURE__*/React.createElement(Select, {
1077
+ title: "custom select title",
1078
+ needSelectDownIcon: needSelectDownIcon
1079
+ }));
1080
+ expect(asFragment()).toMatchSnapshot();
1081
+ });
1082
+ test(`Should render with customProps TextBoxProps - needSelectDownIcon as ${needSelectDownIcon}`, () => {
1083
+ const {
1084
+ asFragment
1085
+ } = render( /*#__PURE__*/React.createElement(Select, {
1086
+ customProps: {
1087
+ TextBoxProps: {
1088
+ 'data-custom-attr': 'true'
1089
+ }
1090
+ },
1091
+ needSelectDownIcon: needSelectDownIcon
1092
+ }));
1093
+ expect(asFragment()).toMatchSnapshot();
1094
+ });
1095
+ });
1096
+ });
1097
+ describe('Select dataId snapshot - ', () => {
1098
+ test('Should render with dataId prop - dropbox open', () => {
1099
+ const {
1100
+ getByRole,
1101
+ asFragment
1102
+ } = render( /*#__PURE__*/React.createElement(Select, {
1103
+ needSearch: true,
1104
+ options: options,
1105
+ dataId: "customDataId"
1106
+ }));
1107
+ userEvent.click(getByRole(selectInputRole));
1108
+ expect(asFragment()).toMatchSnapshot();
1109
+ });
1110
+ test('Should render with dataId prop - isDisabled as true', () => {
1111
+ const {
1112
+ asFragment
1113
+ } = render( /*#__PURE__*/React.createElement(Select, {
1114
+ isDisabled: true,
1115
+ dataId: "customDataId"
1116
+ }));
1117
+ expect(asFragment()).toMatchSnapshot();
1118
+ });
1119
+ test('Should render with dataId prop - isReadOnly as true', () => {
1120
+ const {
1121
+ asFragment
1122
+ } = render( /*#__PURE__*/React.createElement(Select, {
1123
+ isReadOnly: true,
1124
+ dataId: "customDataId"
1125
+ }));
1126
+ expect(asFragment()).toMatchSnapshot();
1127
+ });
1128
+ test('Should render with dataId prop - empty state and needSelectDownIcon as false', () => {
1129
+ const {
1130
+ getByRole,
1131
+ asFragment
1132
+ } = render( /*#__PURE__*/React.createElement(Select, {
1133
+ needSelectDownIcon: false
1134
+ }));
1135
+ userEvent.click(getByRole(selectInputRole));
10
1136
  expect(asFragment()).toMatchSnapshot();
11
1137
  });
12
1138
  });