@ssa-ui-kit/core 1.0.2 → 1.0.4

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 (66) hide show
  1. package/dist/components/Button/fixtures.d.ts +8 -0
  2. package/dist/components/Button/types.d.ts +2 -0
  3. package/dist/components/FormHelperText/FormHelperText.d.ts +1 -1
  4. package/dist/components/ImageItem/ImageItem.d.ts +2 -0
  5. package/dist/components/ImageItem/index.d.ts +1 -0
  6. package/dist/components/ImageItem/types.d.ts +8 -0
  7. package/dist/components/Input/types.d.ts +1 -0
  8. package/dist/components/Label/Label.d.ts +1 -1
  9. package/dist/components/Label/LabelBase.d.ts +2 -0
  10. package/dist/components/Label/types.d.ts +1 -0
  11. package/dist/components/Typeahead/Typeahead.context.d.ts +36 -0
  12. package/dist/components/Typeahead/Typeahead.d.ts +11 -0
  13. package/dist/components/Typeahead/components/MultipleTrigger.d.ts +1 -0
  14. package/dist/components/Typeahead/components/NoOptions.d.ts +1 -0
  15. package/dist/components/Typeahead/components/SingleTrigger.d.ts +1 -0
  16. package/dist/components/Typeahead/components/TypeaheadItem.d.ts +8 -0
  17. package/dist/components/Typeahead/components/TypeaheadOption.d.ts +2 -0
  18. package/dist/components/Typeahead/components/TypeaheadOptions.d.ts +2 -0
  19. package/dist/components/Typeahead/components/TypeaheadTrigger.d.ts +1 -0
  20. package/dist/components/Typeahead/components/index.d.ts +7 -0
  21. package/dist/components/Typeahead/index.d.ts +5 -0
  22. package/dist/components/Typeahead/styles.d.ts +47 -0
  23. package/dist/components/Typeahead/types.d.ts +46 -0
  24. package/dist/components/Typeahead/useTypeahead.d.ts +36 -0
  25. package/dist/components/Typeahead/utils.d.ts +1 -0
  26. package/dist/components/index.d.ts +2 -0
  27. package/dist/index.js +1 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/types/emotion.d.ts +4 -1
  30. package/package.json +3 -3
  31. package/src/components/Badge/Badge.stories.tsx +1 -1
  32. package/src/components/Button/Button.tsx +10 -2
  33. package/src/components/Button/types.ts +2 -0
  34. package/src/components/FormHelperText/FormHelperText.tsx +2 -1
  35. package/src/components/ImageItem/ImageItem.spec.tsx +54 -0
  36. package/src/components/ImageItem/ImageItem.stories.tsx +33 -0
  37. package/src/components/ImageItem/ImageItem.tsx +43 -0
  38. package/src/components/ImageItem/index.ts +1 -0
  39. package/src/components/ImageItem/types.ts +7 -0
  40. package/src/components/Input/Input.spec.tsx +6 -8
  41. package/src/components/Input/Input.tsx +14 -8
  42. package/src/components/Input/types.ts +1 -0
  43. package/src/components/Label/Label.tsx +2 -0
  44. package/src/components/Label/LabelBase.tsx +3 -2
  45. package/src/components/Label/types.ts +1 -0
  46. package/src/components/Typeahead/Typeahead.context.ts +59 -0
  47. package/src/components/Typeahead/Typeahead.spec.tsx +506 -0
  48. package/src/components/Typeahead/Typeahead.stories.tsx +372 -0
  49. package/src/components/Typeahead/Typeahead.tsx +120 -0
  50. package/src/components/Typeahead/components/MultipleTrigger.tsx +116 -0
  51. package/src/components/Typeahead/components/NoOptions.tsx +7 -0
  52. package/src/components/Typeahead/components/SingleTrigger.tsx +71 -0
  53. package/src/components/Typeahead/components/TypeaheadItem.ts +14 -0
  54. package/src/components/Typeahead/components/TypeaheadOption.tsx +12 -0
  55. package/src/components/Typeahead/components/TypeaheadOptions.tsx +25 -0
  56. package/src/components/Typeahead/components/TypeaheadTrigger.tsx +26 -0
  57. package/src/components/Typeahead/components/index.ts +7 -0
  58. package/src/components/Typeahead/index.ts +5 -0
  59. package/src/components/Typeahead/styles.ts +193 -0
  60. package/src/components/Typeahead/types.ts +77 -0
  61. package/src/components/Typeahead/useTypeahead.tsx +321 -0
  62. package/src/components/Typeahead/utils.tsx +22 -0
  63. package/src/components/index.ts +2 -0
  64. package/src/themes/main.ts +3 -0
  65. package/src/types/emotion.ts +3 -0
  66. package/tsbuildcache +1 -1
@@ -0,0 +1,506 @@
1
+ import { within, screen } from '@testing-library/dom';
2
+ import userEvent from '@testing-library/user-event';
3
+ import { Typeahead } from './Typeahead';
4
+ import { highlightInputMatch } from './utils';
5
+ import { TypeaheadOption } from './components';
6
+ import { DynamicallyChangedItems } from './Typeahead.stories';
7
+
8
+ const items = [
9
+ { id: 1, value: 'First' },
10
+ { id: 2, value: 'Second' },
11
+ { id: 3, value: 'Third' },
12
+ { id: 4, label: 'Fourth', value: 4 },
13
+ { id: 5, value: 'Fifth' },
14
+ { id: 6, value: 'Sixth' },
15
+ ];
16
+
17
+ const selectedItems = [items[0], items[4]];
18
+
19
+ const getListItemValue = (item: (typeof items)[0]) => item.value;
20
+ const getListItemLabel = (item: (typeof items)[0]) => item.label || item.value;
21
+
22
+ describe('Typeahead', () => {
23
+ const originalConsoleWarn = console.warn;
24
+ function setup(props = {}) {
25
+ const mockOnChange = jest.fn();
26
+
27
+ return {
28
+ user: userEvent.setup(),
29
+ mockOnChange,
30
+ ...render(
31
+ <Typeahead
32
+ isDisabled={false}
33
+ name={'typeahead-dropdown'}
34
+ label="Label"
35
+ register={jest.fn()}
36
+ setValue={mockOnChange}
37
+ validationSchema={{
38
+ required: 'Required',
39
+ }}
40
+ renderOption={({ label, input }) => highlightInputMatch(label, input)}
41
+ {...props}>
42
+ {items.map(({ value, id }) => (
43
+ <TypeaheadOption key={id} value={id} label={value}>
44
+ {value}
45
+ </TypeaheadOption>
46
+ ))}
47
+ </Typeahead>,
48
+ ),
49
+ };
50
+ }
51
+
52
+ beforeEach(() => {
53
+ console.warn = jest.fn();
54
+ });
55
+
56
+ afterEach(() => {
57
+ console.warn = originalConsoleWarn;
58
+ });
59
+
60
+ it('Renders without a selected item', async () => {
61
+ const { user, mockOnChange, getByRole, queryByRole, getByTestId } = setup();
62
+
63
+ expect(mockOnChange).toBeCalledWith('typeahead-dropdown', undefined);
64
+
65
+ const mainElement = getByTestId('typeahead');
66
+
67
+ let toggleElement = within(mainElement).getByRole('combobox');
68
+ expect(screen.getByPlaceholderText('Select something'));
69
+ expect(toggleElement).toHaveAttribute('aria-expanded', 'false');
70
+ expect(toggleElement).toHaveAttribute('aria-haspopup', 'dialog');
71
+ expect(toggleElement).toHaveAttribute('aria-controls');
72
+ expect(toggleElement).toHaveAttribute('aria-labelledby');
73
+
74
+ let listboxEl = queryByRole('listbox');
75
+ expect(listboxEl).not.toBeInTheDocument();
76
+
77
+ let inputEl = screen.queryByTestId('typeahead-input');
78
+ await user.click(inputEl as HTMLElement);
79
+
80
+ listboxEl = getByRole('listbox');
81
+ const listItemEls = within(listboxEl).getAllByRole('option');
82
+ expect(listItemEls.length).toBe(items.length);
83
+
84
+ toggleElement = within(mainElement).getByRole('combobox');
85
+ inputEl = screen.queryByTestId('typeahead-input');
86
+ expect(inputEl).toHaveFocus();
87
+ expect(toggleElement).toHaveAttribute('aria-expanded', 'true');
88
+
89
+ for (let i = 0; i < items.length; ++i) {
90
+ const listItem = items[i];
91
+ const listItemEl = listItemEls[i];
92
+ expect(listItemEl).toHaveAttribute('aria-selected', 'false');
93
+ const itemListValue = getListItemValue(listItem);
94
+ expect(listItemEl).toHaveTextContent(`${itemListValue}`);
95
+ await within(listItemEl).findByText(itemListValue);
96
+ }
97
+ });
98
+
99
+ it('Renders with a selected item', async () => {
100
+ const selectedIDs = selectedItems.map((item) => item.id);
101
+ const { user, mockOnChange, getByRole, queryByRole, getByTestId } = setup({
102
+ initialSelectedItems: selectedIDs,
103
+ isMultiple: true,
104
+ label: 'Label',
105
+ });
106
+
107
+ expect(mockOnChange).toBeCalledWith('typeahead-dropdown', selectedIDs);
108
+
109
+ let mainElement = getByTestId('typeahead');
110
+
111
+ let toggleElement = within(mainElement).getByRole('combobox');
112
+ expect(
113
+ screen.queryByPlaceholderText('Select something'),
114
+ ).not.toBeInTheDocument();
115
+ expect(toggleElement).toHaveAttribute('aria-expanded', 'false');
116
+ expect(toggleElement).toHaveAttribute('aria-haspopup', 'dialog');
117
+ expect(toggleElement).toHaveAttribute('aria-controls');
118
+ expect(toggleElement).toHaveAttribute('aria-labelledby');
119
+
120
+ mainElement = getByTestId('typeahead');
121
+ toggleElement = within(mainElement).getByRole('combobox');
122
+ for (let i = 0; i < selectedItems.length; i++) {
123
+ const tokenValue = selectedItems[i].value;
124
+ within(toggleElement).getByText(tokenValue);
125
+ }
126
+
127
+ let listboxEl = queryByRole('listbox');
128
+ expect(listboxEl).not.toBeInTheDocument();
129
+
130
+ let inputEl = screen.queryByTestId('typeahead-input');
131
+ await user.click(inputEl as HTMLElement);
132
+
133
+ listboxEl = getByRole('listbox');
134
+ const listItemEls = within(listboxEl).getAllByRole('option');
135
+ expect(listItemEls.length).toBe(items.length);
136
+
137
+ toggleElement = within(mainElement).getByRole('combobox');
138
+ inputEl = screen.queryByTestId('typeahead-input');
139
+ expect(inputEl).toHaveFocus();
140
+ expect(toggleElement).toHaveAttribute('aria-expanded', 'true');
141
+
142
+ for (let i = 0; i < items.length; ++i) {
143
+ const listItem = items[i];
144
+ const listItemEl = listItemEls[i];
145
+ expect(listItemEl).toHaveAttribute(
146
+ 'aria-selected',
147
+ `${selectedIDs.includes(listItem.id)}`,
148
+ );
149
+ const itemListValue = getListItemValue(listItem);
150
+ expect(listItemEl).toHaveTextContent(`${itemListValue}`);
151
+ await within(listItemEl).findByText(itemListValue);
152
+ }
153
+ });
154
+
155
+ it('Renders with an empty items array', async () => {
156
+ const mockOnChange = jest.fn();
157
+ const { getByTestId, queryByRole } = render(
158
+ <Typeahead
159
+ isMultiple
160
+ name={'typeahead-dropdown'}
161
+ label="Label"
162
+ register={jest.fn()}
163
+ setValue={mockOnChange}
164
+ />,
165
+ );
166
+
167
+ expect(mockOnChange).toBeCalledWith('typeahead-dropdown', []);
168
+
169
+ let mainElement = getByTestId('typeahead');
170
+
171
+ let toggleElement = within(mainElement).getByRole('combobox');
172
+ expect(
173
+ screen.queryByPlaceholderText('Select something'),
174
+ ).toBeInTheDocument();
175
+ expect(toggleElement).toHaveAttribute('aria-expanded', 'false');
176
+ expect(toggleElement).toHaveAttribute('aria-haspopup', 'dialog');
177
+ expect(toggleElement).toHaveAttribute('aria-controls');
178
+ expect(toggleElement).toHaveAttribute('aria-labelledby');
179
+
180
+ mainElement = getByTestId('typeahead');
181
+ toggleElement = within(mainElement).getByRole('combobox');
182
+
183
+ let listboxEl = queryByRole('listbox');
184
+ expect(listboxEl).not.toBeInTheDocument();
185
+
186
+ const inputEl = screen.queryByTestId('typeahead-input');
187
+ await userEvent.click(inputEl as HTMLElement);
188
+
189
+ listboxEl = queryByRole('listbox');
190
+ const listItemEl = within(listboxEl as HTMLElement).getByRole('option');
191
+
192
+ expect(listItemEl).toHaveAttribute('aria-selected', 'false');
193
+ within(listItemEl).getByText('No matches found');
194
+ expect(inputEl).toHaveFocus();
195
+ expect(toggleElement).toHaveAttribute('aria-expanded', 'true');
196
+ });
197
+
198
+ it("Chooses an item when it's clicked [isMultiple = true]", async () => {
199
+ const selectedIDs = selectedItems.map((item) => item.id);
200
+ const { user, mockOnChange, getByRole, getByTestId } = setup({
201
+ initialSelectedItems: selectedIDs,
202
+ isMultiple: true,
203
+ label: 'Label',
204
+ });
205
+
206
+ expect(mockOnChange).toBeCalledWith('typeahead-dropdown', selectedIDs);
207
+
208
+ const mainElement = getByTestId('typeahead');
209
+
210
+ let toggleElement = within(mainElement).getByRole('combobox');
211
+
212
+ expect(toggleElement).toHaveTextContent('FirstRemoveFifthRemoveRemove');
213
+
214
+ const inputEl = screen.queryByTestId('typeahead-input');
215
+ await user.click(inputEl as HTMLElement);
216
+
217
+ const listboxEl = getByRole('listbox');
218
+ const listItemEls = within(listboxEl).getAllByRole('option');
219
+ await user.click(listItemEls[0]);
220
+
221
+ toggleElement = within(mainElement).getByRole('combobox');
222
+
223
+ expect(toggleElement).toHaveTextContent('FifthRemoveRemove');
224
+
225
+ for (let i = 0; i < items.length; ++i) {
226
+ const listItem = items[i];
227
+ const listItemEl = listItemEls[i];
228
+ expect(listItemEl).toHaveAttribute(
229
+ 'aria-selected',
230
+ `${selectedIDs.includes(listItem.id)}`,
231
+ );
232
+ const itemListValue = getListItemValue(listItem);
233
+ expect(listItemEl).toHaveTextContent(`${itemListValue}`);
234
+ await within(listItemEl).findByText(itemListValue);
235
+ }
236
+ });
237
+
238
+ it("Chooses an item when it's clicked [isMultiple = false]", async () => {
239
+ const selectedIDs = [selectedItems[0].id];
240
+ const { user, mockOnChange, getByRole } = setup({
241
+ initialSelectedItems: selectedIDs,
242
+ isMultiple: false,
243
+ label: 'Label',
244
+ });
245
+
246
+ expect(mockOnChange).lastCalledWith('typeahead-dropdown', selectedIDs[0]);
247
+
248
+ let inputEl = screen.queryByTestId('typeahead-input');
249
+ expect(inputEl).toHaveValue('First');
250
+ await user.click(inputEl as HTMLElement);
251
+
252
+ let listboxEl = getByRole('listbox');
253
+ let listItemEls = within(listboxEl).getAllByRole('option');
254
+ await user.click(listItemEls[1]);
255
+
256
+ inputEl = screen.queryByTestId('typeahead-input');
257
+ expect(inputEl).toHaveValue('Second');
258
+
259
+ await user.click(inputEl as HTMLElement);
260
+
261
+ listboxEl = getByRole('listbox');
262
+ listItemEls = within(listboxEl).getAllByRole('option');
263
+
264
+ for (let i = 0; i < items.length; ++i) {
265
+ const listItem = items[i];
266
+ const listItemEl = listItemEls[i];
267
+ expect(listItemEl).toHaveAttribute(
268
+ 'aria-selected',
269
+ `${[2].includes(listItem.id)}`,
270
+ );
271
+ const itemListValue = getListItemValue(listItem);
272
+ expect(listItemEl).toHaveTextContent(`${itemListValue}`);
273
+ await within(listItemEl).findByText(itemListValue);
274
+ }
275
+ });
276
+
277
+ it('Closes when clicked outside', async () => {
278
+ const { user, getByRole, queryByRole } = setup();
279
+
280
+ await user.click(getByRole('combobox'));
281
+ getByRole('listbox');
282
+
283
+ await user.click(document.body);
284
+
285
+ expect(queryByRole('listbox')).not.toBeInTheDocument();
286
+
287
+ // Doesn't open up when clicked outside again
288
+ await user.click(document.body);
289
+
290
+ expect(queryByRole('listbox')).not.toBeInTheDocument();
291
+ });
292
+
293
+ it('Toggle option if clicked on the same option', async () => {
294
+ const selectedIDs = [selectedItems[0].id];
295
+ const { user, getByRole, getByTestId } = setup({
296
+ initialSelectedItems: selectedIDs,
297
+ isMultiple: false,
298
+ label: 'Label',
299
+ });
300
+
301
+ const mainElement = getByTestId('typeahead');
302
+ const toggleElement = within(mainElement).getByRole('combobox');
303
+
304
+ let inputEl = screen.queryByTestId('typeahead-input');
305
+ expect(inputEl).toHaveValue('First');
306
+
307
+ for (let i = 0; i < 2; i++) {
308
+ await user.click(toggleElement);
309
+
310
+ const listboxEl = getByRole('listbox');
311
+ const listItemEls = within(listboxEl).getAllByRole('option');
312
+
313
+ await user.click(listItemEls[0]);
314
+
315
+ inputEl = screen.queryByTestId('typeahead-input');
316
+ expect(inputEl).toHaveValue(i === 0 ? '' : 'First');
317
+ }
318
+ });
319
+
320
+ it('Renders with a custom placeholder', () => {
321
+ setup({
322
+ placeholder: 'Choose at least one option',
323
+ });
324
+
325
+ expect(screen.getByPlaceholderText('Choose at least one option'));
326
+ });
327
+
328
+ it('Renders without any placeholder', () => {
329
+ setup({
330
+ placeholder: null,
331
+ });
332
+
333
+ expect(screen.getByTestId('typeahead-input')).not.toHaveAttribute(
334
+ 'placeholder',
335
+ '',
336
+ );
337
+ });
338
+
339
+ it('Renders in the disabled state', async () => {
340
+ const selectedIDs = selectedItems.map((item) => item.id);
341
+ const { user, mockOnChange, queryByRole, getByTestId } = setup({
342
+ initialSelectedItems: selectedIDs,
343
+ isMultiple: true,
344
+ isDisabled: true,
345
+ label: 'Label',
346
+ });
347
+
348
+ expect(mockOnChange).toBeCalledWith('typeahead-dropdown', selectedIDs);
349
+
350
+ let mainElement = getByTestId('typeahead');
351
+
352
+ let toggleElement = within(mainElement).getByRole('combobox');
353
+ expect(
354
+ screen.queryByPlaceholderText('Select something'),
355
+ ).not.toBeInTheDocument();
356
+ expect(toggleElement).toHaveAttribute('disabled');
357
+
358
+ mainElement = getByTestId('typeahead');
359
+ toggleElement = within(mainElement).getByRole('combobox');
360
+
361
+ let listboxEl = queryByRole('listbox');
362
+ expect(listboxEl).not.toBeInTheDocument();
363
+
364
+ const inputEl = screen.queryByTestId('typeahead-input');
365
+ await user.click(inputEl as HTMLElement);
366
+
367
+ listboxEl = queryByRole('listbox');
368
+ expect(listboxEl).not.toBeInTheDocument();
369
+ });
370
+
371
+ it('Closes when changes state to disabled', async () => {
372
+ const { rerender, user, queryByRole, getByTestId } = setup();
373
+
374
+ const mainElement = getByTestId('typeahead');
375
+ const toggleElement = within(mainElement).getByRole('combobox');
376
+
377
+ await user.click(toggleElement);
378
+
379
+ expect(queryByRole('listbox')).toBeInTheDocument();
380
+
381
+ rerender(
382
+ <Typeahead
383
+ isDisabled
384
+ name={'typeahead-dropdown'}
385
+ label="Label"
386
+ register={jest.fn()}
387
+ setValue={jest.fn()}
388
+ validationSchema={{
389
+ required: 'Required',
390
+ }}
391
+ renderOption={({ label, input }) => highlightInputMatch(label, input)}>
392
+ {items.map(({ value, id }) => (
393
+ <TypeaheadOption key={id} value={id} label={value}>
394
+ {value}
395
+ </TypeaheadOption>
396
+ ))}
397
+ </Typeahead>,
398
+ );
399
+
400
+ expect(queryByRole('listbox')).not.toBeInTheDocument();
401
+ });
402
+
403
+ it('Renders opened', () => {
404
+ const { queryByRole } = setup({ isOpen: true });
405
+
406
+ expect(queryByRole('listbox')).toBeInTheDocument();
407
+ });
408
+
409
+ it('New item should be rendered correctly', async () => {
410
+ const { getByTestId, getByText, getByRole } = render(
411
+ <DynamicallyChangedItems initialSelectedItems={[]} />,
412
+ );
413
+
414
+ const mainElement = getByTestId('typeahead');
415
+ const toggleElement = within(mainElement).getByRole('combobox');
416
+
417
+ await userEvent.click(toggleElement);
418
+
419
+ let listboxEl = getByRole('listbox');
420
+ let listItemEls = within(listboxEl).getAllByRole('option');
421
+
422
+ for (let i = 0; i < items.length; ++i) {
423
+ const listItem = items[i];
424
+ const listItemEl = listItemEls[i];
425
+ expect(listItemEl).toHaveAttribute('aria-selected', `false`);
426
+ const itemListLabel = getListItemLabel(listItem);
427
+ expect(listItemEl).toHaveTextContent(`${itemListLabel}`);
428
+ // await within(listItemEl).findByText(itemListLabel);
429
+ }
430
+
431
+ const updateItemsButton = getByText('Update items');
432
+ await userEvent.click(updateItemsButton);
433
+
434
+ await userEvent.click(toggleElement);
435
+
436
+ listboxEl = getByRole('listbox');
437
+ listItemEls = within(listboxEl).getAllByRole('option');
438
+ expect(listItemEls[listItemEls.length - 1]).toHaveTextContent(
439
+ 'New item #7',
440
+ );
441
+ });
442
+
443
+ it('"Remove all" functionality should be worked', async () => {
444
+ const selectedIDs = selectedItems.map((item) => item.id);
445
+ const { mockOnChange, getByRole, getByTestId } = setup({
446
+ initialSelectedItems: selectedIDs,
447
+ isMultiple: true,
448
+ label: 'Label',
449
+ });
450
+
451
+ expect(mockOnChange).toBeCalledWith('typeahead-dropdown', selectedIDs);
452
+
453
+ let mainElement = getByTestId('typeahead');
454
+ let toggleElement = within(mainElement).getByRole('combobox');
455
+
456
+ expect(toggleElement).toHaveTextContent('FirstRemoveFifthRemoveRemove');
457
+
458
+ const crossAllButton =
459
+ within(toggleElement).getByTestId('remove-all-button');
460
+ await userEvent.click(crossAllButton);
461
+
462
+ mainElement = getByTestId('typeahead');
463
+ toggleElement = within(mainElement).getByRole('combobox');
464
+
465
+ expect(toggleElement).toHaveTextContent('');
466
+
467
+ await userEvent.click(toggleElement);
468
+ const listboxEl = getByRole('listbox');
469
+ const listItemEls = within(listboxEl).getAllByRole('option');
470
+
471
+ for (let i = 0; i < items.length; ++i) {
472
+ const listItem = items[i];
473
+ const listItemEl = listItemEls[i];
474
+ expect(listItemEl).toHaveAttribute('aria-selected', `false`);
475
+ const itemListValue = getListItemValue(listItem);
476
+ expect(listItemEl).toHaveTextContent(`${itemListValue}`);
477
+ await within(listItemEl).findByText(itemListValue);
478
+ }
479
+ });
480
+
481
+ it('Helper text should be displayed', () => {
482
+ const selectedIDs = selectedItems.map((item) => item.id);
483
+ const { getByTestId } = setup({
484
+ initialSelectedItems: selectedIDs,
485
+ isMultiple: true,
486
+ label: 'Label',
487
+ helperText: 'Helper text',
488
+ });
489
+
490
+ expect(getByTestId('helper-text')).toBeInTheDocument();
491
+ });
492
+
493
+ it('Error should be displayed', () => {
494
+ const selectedIDs = selectedItems.map((item) => item.id);
495
+ const { getByTestId } = setup({
496
+ initialSelectedItems: selectedIDs,
497
+ isMultiple: true,
498
+ label: 'Label',
499
+ errors: {
500
+ message: 'Error message',
501
+ },
502
+ });
503
+
504
+ expect(getByTestId('helper-text')).toBeInTheDocument();
505
+ });
506
+ });