@qoretechnologies/reqore 0.31.2 → 0.32.0

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 (56) hide show
  1. package/__tests__/collection.test.tsx +5 -1
  2. package/__tests__/input.test.tsx +417 -24
  3. package/__tests__/multiselect.test.tsx +8 -10
  4. package/__tests__/textarea.test.tsx +405 -24
  5. package/dist/components/Button/index.d.ts.map +1 -1
  6. package/dist/components/Button/index.js +1 -1
  7. package/dist/components/Button/index.js.map +1 -1
  8. package/dist/components/Collection/index.d.ts +3 -2
  9. package/dist/components/Collection/index.d.ts.map +1 -1
  10. package/dist/components/Collection/index.js +6 -3
  11. package/dist/components/Collection/index.js.map +1 -1
  12. package/dist/components/ControlGroup/index.d.ts.map +1 -1
  13. package/dist/components/ControlGroup/index.js +17 -56
  14. package/dist/components/ControlGroup/index.js.map +1 -1
  15. package/dist/components/Icon/index.d.ts +2 -0
  16. package/dist/components/Icon/index.d.ts.map +1 -1
  17. package/dist/components/Icon/index.js +10 -5
  18. package/dist/components/Icon/index.js.map +1 -1
  19. package/dist/components/Input/index.d.ts +4 -0
  20. package/dist/components/Input/index.d.ts.map +1 -1
  21. package/dist/components/Input/index.js +18 -6
  22. package/dist/components/Input/index.js.map +1 -1
  23. package/dist/components/InputClearButton/index.d.ts +1 -0
  24. package/dist/components/InputClearButton/index.d.ts.map +1 -1
  25. package/dist/components/InputClearButton/index.js +18 -8
  26. package/dist/components/InputClearButton/index.js.map +1 -1
  27. package/dist/components/Panel/index.d.ts.map +1 -1
  28. package/dist/components/Panel/index.js +11 -6
  29. package/dist/components/Panel/index.js.map +1 -1
  30. package/dist/components/Textarea/index.d.ts +2 -0
  31. package/dist/components/Textarea/index.d.ts.map +1 -1
  32. package/dist/components/Textarea/index.js +4 -2
  33. package/dist/components/Textarea/index.js.map +1 -1
  34. package/dist/hooks/useAutoFocus.d.ts +11 -0
  35. package/dist/hooks/useAutoFocus.d.ts.map +1 -0
  36. package/dist/hooks/useAutoFocus.js +80 -0
  37. package/dist/hooks/useAutoFocus.js.map +1 -0
  38. package/dist/styles.d.ts.map +1 -1
  39. package/dist/styles.js +1 -1
  40. package/dist/styles.js.map +1 -1
  41. package/package.json +3 -1
  42. package/src/components/Button/index.tsx +1 -0
  43. package/src/components/Collection/index.tsx +12 -2
  44. package/src/components/ControlGroup/index.tsx +25 -86
  45. package/src/components/Icon/index.tsx +18 -4
  46. package/src/components/Input/index.tsx +38 -3
  47. package/src/components/InputClearButton/index.tsx +41 -17
  48. package/src/components/Panel/index.tsx +18 -8
  49. package/src/components/Textarea/index.tsx +15 -8
  50. package/src/hooks/useAutoFocus.ts +104 -0
  51. package/src/stories/Collection/Collection.stories.tsx +54 -10
  52. package/src/stories/Input/Input.stories.tsx +29 -6
  53. package/src/stories/Panel/Panel.stories.tsx +3 -2
  54. package/src/stories/TextArea/TextArea.stories.tsx +1 -0
  55. package/src/styles.ts +0 -1
  56. package/tests.json +1 -1
@@ -1,3 +1,4 @@
1
+ import '@testing-library/jest-dom/extend-expect';
1
2
  import { fireEvent, render } from '@testing-library/react';
2
3
  import React from 'react';
3
4
  import { ReqoreCollection, ReqoreLayoutContent, ReqoreUIProvider } from '../src';
@@ -17,10 +18,12 @@ test('Renders basic <Collection /> properly', () => {
17
18
  });
18
19
 
19
20
  test('<Collection /> items can be filtered', () => {
21
+ const fn = jest.fn();
22
+
20
23
  render(
21
24
  <ReqoreUIProvider>
22
25
  <ReqoreLayoutContent>
23
- <ReqoreCollection items={items} filterable />
26
+ <ReqoreCollection items={items} filterable onQueryChange={fn} />
24
27
  </ReqoreLayoutContent>
25
28
  </ReqoreUIProvider>
26
29
  );
@@ -29,6 +32,7 @@ test('<Collection /> items can be filtered', () => {
29
32
  target: { value: 'I have' },
30
33
  });
31
34
 
35
+ expect(fn).toHaveBeenCalledWith('I have');
32
36
  expect(document.querySelectorAll('.reqore-collection-item').length).toBe(2);
33
37
 
34
38
  fireEvent.change(document.querySelector('.reqore-input')!, {
@@ -1,57 +1,61 @@
1
- import { fireEvent, render } from "@testing-library/react";
2
- import { noop } from "lodash";
3
- import React from "react";
4
- import {
5
- ReqoreContent,
6
- ReqoreInput,
7
- ReqoreLayoutContent,
8
- ReqoreUIProvider,
9
- } from "../src";
1
+ import { Globals } from '@react-spring/web';
2
+ import '@testing-library/jest-dom/extend-expect';
3
+ import { fireEvent, render } from '@testing-library/react';
4
+ import { noop } from 'lodash';
5
+ import React from 'react';
6
+ import { mockAllIsIntersecting } from 'react-intersection-observer/test-utils';
7
+ import { ReqoreContent, ReqoreInput, ReqoreLayoutContent, ReqoreUIProvider } from '../src';
10
8
 
11
- test("Renders <Input /> properly", () => {
9
+ beforeAll(() => {
10
+ Globals.assign({
11
+ skipAnimation: true,
12
+ });
13
+ });
14
+
15
+ test('Renders <Input /> properly', () => {
12
16
  render(
13
17
  <ReqoreUIProvider>
14
18
  <ReqoreLayoutContent>
15
19
  <ReqoreContent>
16
20
  <ReqoreInput minimal />
17
21
  <ReqoreInput disabled />
18
- <ReqoreInput size="big" />
22
+ <ReqoreInput size='big' />
19
23
  </ReqoreContent>
20
24
  </ReqoreLayoutContent>
21
25
  </ReqoreUIProvider>
22
26
  );
23
27
 
24
- expect(document.querySelectorAll(".reqore-input").length).toBe(3);
28
+ expect(document.querySelectorAll('.reqore-input').length).toBe(3);
25
29
  // No clear button
26
- expect(document.querySelectorAll(".reqore-clear-input-button").length).toBe(
27
- 0
28
- );
30
+ expect(document.querySelectorAll('.reqore-clear-input-button').length).toBe(0);
29
31
  });
30
32
 
31
- test("Renders <Input /> with clear button properly", () => {
33
+ test('Renders <Input /> with clear button properly', async () => {
34
+ jest.useFakeTimers();
35
+
32
36
  const fn = jest.fn();
33
37
 
34
38
  render(
35
39
  <ReqoreUIProvider>
36
40
  <ReqoreLayoutContent>
37
41
  <ReqoreContent>
38
- <ReqoreInput minimal onChange={noop} onClearClick={fn} />
42
+ <ReqoreInput minimal onChange={noop} onClearClick={fn} value='test' />
39
43
  </ReqoreContent>
40
44
  </ReqoreLayoutContent>
41
45
  </ReqoreUIProvider>
42
46
  );
43
47
 
48
+ jest.advanceTimersByTime(1000);
49
+
44
50
  // No clear button
45
- expect(document.querySelectorAll(".reqore-clear-input-button").length).toBe(
46
- 1
47
- );
51
+ expect(document.querySelectorAll('.reqore-clear-input-button').length).toBe(1);
48
52
 
49
- fireEvent.click(document.querySelector(".reqore-clear-input-button"));
53
+ fireEvent.click(document.querySelector('.reqore-clear-input-button')!);
50
54
 
51
55
  expect(fn).toHaveBeenCalled();
52
56
  });
53
57
 
54
- test("Disabled <Input /> cannot be cleared", () => {
58
+ test('Disabled <Input /> cannot be cleared', () => {
55
59
  const fn = jest.fn();
56
60
 
57
61
  render(
@@ -65,7 +69,396 @@ test("Disabled <Input /> cannot be cleared", () => {
65
69
  );
66
70
 
67
71
  // No clear button
68
- expect(document.querySelectorAll(".reqore-clear-input-button").length).toBe(
69
- 0
72
+ expect(document.querySelectorAll('.reqore-clear-input-button').length).toBe(0);
73
+ });
74
+
75
+ test('Readonly <Input /> cannot be cleared', () => {
76
+ const fn = jest.fn();
77
+
78
+ render(
79
+ <ReqoreUIProvider>
80
+ <ReqoreLayoutContent>
81
+ <ReqoreContent>
82
+ <ReqoreInput minimal onChange={noop} onClearClick={fn} readOnly />
83
+ </ReqoreContent>
84
+ </ReqoreLayoutContent>
85
+ </ReqoreUIProvider>
70
86
  );
87
+
88
+ // No clear button
89
+ expect(document.querySelectorAll('.reqore-clear-input-button').length).toBe(0);
90
+ });
91
+
92
+ test('<Input /> gets automatically focused', () => {
93
+ render(
94
+ <ReqoreUIProvider>
95
+ <ReqoreLayoutContent>
96
+ <ReqoreContent>
97
+ <ReqoreInput focusRules={{ type: 'auto' }} />
98
+ </ReqoreContent>
99
+ </ReqoreLayoutContent>
100
+ </ReqoreUIProvider>
101
+ );
102
+
103
+ expect(document.querySelectorAll('.reqore-input')[0]).toHaveFocus();
104
+ });
105
+
106
+ test('Readonly <Input /> does not get automatically focused', () => {
107
+ render(
108
+ <ReqoreUIProvider>
109
+ <ReqoreLayoutContent>
110
+ <ReqoreContent>
111
+ <ReqoreInput focusRules={{ type: 'auto' }} readOnly />
112
+ </ReqoreContent>
113
+ </ReqoreLayoutContent>
114
+ </ReqoreUIProvider>
115
+ );
116
+
117
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
118
+ });
119
+
120
+ test('Disabled <Input /> does not get automatically focused', () => {
121
+ render(
122
+ <ReqoreUIProvider>
123
+ <ReqoreLayoutContent>
124
+ <ReqoreContent>
125
+ <ReqoreInput focusRules={{ type: 'auto' }} disabled />
126
+ </ReqoreContent>
127
+ </ReqoreLayoutContent>
128
+ </ReqoreUIProvider>
129
+ );
130
+
131
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
132
+ });
133
+
134
+ test("<Input /> gets automatically focused if it's out of viewport", () => {
135
+ render(
136
+ <ReqoreUIProvider>
137
+ <ReqoreLayoutContent>
138
+ <ReqoreContent>
139
+ <div style={{ height: '100vh' }} />
140
+ <ReqoreInput focusRules={{ type: 'auto' }} />
141
+ </ReqoreContent>
142
+ </ReqoreLayoutContent>
143
+ </ReqoreUIProvider>
144
+ );
145
+
146
+ expect(document.querySelectorAll('.reqore-input')[0]).toHaveFocus();
147
+ });
148
+
149
+ test("<Input /> does not get automatically focused if it's out of viewport", () => {
150
+ render(
151
+ <ReqoreUIProvider>
152
+ <ReqoreLayoutContent>
153
+ <ReqoreContent>
154
+ <div style={{ height: '100vh' }} />
155
+ <ReqoreInput focusRules={{ type: 'auto', viewportOnly: true }} />
156
+ </ReqoreContent>
157
+ </ReqoreLayoutContent>
158
+ </ReqoreUIProvider>
159
+ );
160
+
161
+ mockAllIsIntersecting(false);
162
+
163
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
164
+ });
165
+
166
+ test('<Input /> gets automatically focused if its inside of viewport', () => {
167
+ render(
168
+ <ReqoreUIProvider>
169
+ <ReqoreLayoutContent>
170
+ <ReqoreContent>
171
+ <ReqoreInput focusRules={{ type: 'auto', viewportOnly: true }} />
172
+ </ReqoreContent>
173
+ </ReqoreLayoutContent>
174
+ </ReqoreUIProvider>
175
+ );
176
+
177
+ mockAllIsIntersecting(true);
178
+
179
+ expect(document.querySelectorAll('.reqore-input')[0]).toHaveFocus();
180
+ });
181
+
182
+ test('<Input /> gets focused after any letter is pressed', () => {
183
+ render(
184
+ <ReqoreUIProvider>
185
+ <ReqoreLayoutContent>
186
+ <ReqoreContent>
187
+ <ReqoreInput focusRules={{ type: 'keypress', shortcut: 'letters' }} />
188
+ </ReqoreContent>
189
+ </ReqoreLayoutContent>
190
+ </ReqoreUIProvider>
191
+ );
192
+
193
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
194
+
195
+ fireEvent.keyDown(document, {
196
+ key: 'a',
197
+ });
198
+
199
+ expect(document.querySelectorAll('.reqore-input')[0]).toHaveFocus();
200
+ });
201
+
202
+ test('<Input /> gets focused after any letter is pressed 2', () => {
203
+ render(
204
+ <ReqoreUIProvider>
205
+ <ReqoreLayoutContent>
206
+ <ReqoreContent>
207
+ <ReqoreInput focusRules={{ type: 'keypress', shortcut: 'letters' }} />
208
+ </ReqoreContent>
209
+ </ReqoreLayoutContent>
210
+ </ReqoreUIProvider>
211
+ );
212
+
213
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
214
+
215
+ fireEvent.keyDown(document, {
216
+ key: '2',
217
+ });
218
+
219
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
220
+
221
+ fireEvent.keyDown(document, {
222
+ key: 'L',
223
+ });
224
+
225
+ expect(document.querySelectorAll('.reqore-input')[0]).toHaveFocus();
226
+ });
227
+
228
+ test('<Input /> gets focused after any digit is pressed', () => {
229
+ render(
230
+ <ReqoreUIProvider>
231
+ <ReqoreLayoutContent>
232
+ <ReqoreContent>
233
+ <ReqoreInput focusRules={{ type: 'keypress', shortcut: 'numbers' }} />
234
+ </ReqoreContent>
235
+ </ReqoreLayoutContent>
236
+ </ReqoreUIProvider>
237
+ );
238
+
239
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
240
+
241
+ fireEvent.keyDown(document, {
242
+ key: '1',
243
+ });
244
+
245
+ expect(document.querySelectorAll('.reqore-input')[0]).toHaveFocus();
246
+ });
247
+
248
+ test('<Input /> gets focused after any digit is pressed 2', () => {
249
+ render(
250
+ <ReqoreUIProvider>
251
+ <ReqoreLayoutContent>
252
+ <ReqoreContent>
253
+ <ReqoreInput focusRules={{ type: 'keypress', shortcut: 'numbers' }} />
254
+ </ReqoreContent>
255
+ </ReqoreLayoutContent>
256
+ </ReqoreUIProvider>
257
+ );
258
+
259
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
260
+
261
+ fireEvent.keyDown(document, {
262
+ key: 'u',
263
+ });
264
+
265
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
266
+
267
+ fireEvent.keyDown(document, {
268
+ key: '0',
269
+ });
270
+
271
+ expect(document.querySelectorAll('.reqore-input')[0]).toHaveFocus();
272
+ });
273
+
274
+ test('<Input /> gets focused after any digit or letter is pressed', () => {
275
+ render(
276
+ <ReqoreUIProvider>
277
+ <ReqoreLayoutContent>
278
+ <ReqoreContent>
279
+ <ReqoreInput focusRules={{ type: 'keypress', shortcut: ['numbers', 'letters'] }} />
280
+ </ReqoreContent>
281
+ </ReqoreLayoutContent>
282
+ </ReqoreUIProvider>
283
+ );
284
+
285
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
286
+
287
+ fireEvent.keyDown(document, {
288
+ key: 'm',
289
+ });
290
+
291
+ expect(document.querySelectorAll('.reqore-input')[0]).toHaveFocus();
292
+ });
293
+
294
+ test('<Input /> gets focused after any digit or letter is pressed 2', () => {
295
+ render(
296
+ <ReqoreUIProvider>
297
+ <ReqoreLayoutContent>
298
+ <ReqoreContent>
299
+ <ReqoreInput focusRules={{ type: 'keypress', shortcut: ['numbers', 'letters'] }} />
300
+ </ReqoreContent>
301
+ </ReqoreLayoutContent>
302
+ </ReqoreUIProvider>
303
+ );
304
+
305
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
306
+
307
+ fireEvent.keyDown(document, {
308
+ key: '5',
309
+ });
310
+
311
+ expect(document.querySelectorAll('.reqore-input')[0]).toHaveFocus();
312
+ });
313
+
314
+ test('<Input /> gets focused after a specified shortcut is pressed', () => {
315
+ render(
316
+ <ReqoreUIProvider>
317
+ <ReqoreLayoutContent>
318
+ <ReqoreContent>
319
+ <ReqoreInput focusRules={{ type: 'keypress', shortcut: 's' }} />
320
+ </ReqoreContent>
321
+ </ReqoreLayoutContent>
322
+ </ReqoreUIProvider>
323
+ );
324
+
325
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
326
+
327
+ fireEvent.keyDown(document, {
328
+ key: 'u',
329
+ });
330
+
331
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
332
+
333
+ fireEvent.keyDown(document, {
334
+ key: '0',
335
+ });
336
+
337
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
338
+
339
+ fireEvent.keyDown(document, {
340
+ key: 's',
341
+ });
342
+
343
+ expect(document.querySelectorAll('.reqore-input')[0]).toHaveFocus();
344
+ });
345
+
346
+ test("<Input /> does not get focused after a specified shortcut is pressed if it's not in Viewport, get's focused when in viewport", () => {
347
+ render(
348
+ <ReqoreUIProvider>
349
+ <ReqoreLayoutContent>
350
+ <ReqoreContent>
351
+ <ReqoreInput focusRules={{ type: 'keypress', shortcut: 's', viewportOnly: true }} />
352
+ </ReqoreContent>
353
+ </ReqoreLayoutContent>
354
+ </ReqoreUIProvider>
355
+ );
356
+
357
+ mockAllIsIntersecting(false);
358
+
359
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
360
+
361
+ fireEvent.keyDown(document, {
362
+ key: 's',
363
+ });
364
+
365
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
366
+
367
+ mockAllIsIntersecting(true);
368
+
369
+ fireEvent.keyDown(document, {
370
+ key: 's',
371
+ });
372
+
373
+ expect(document.querySelectorAll('.reqore-input')[0]).toHaveFocus();
374
+ });
375
+
376
+ test('<Input /> does not get focused when typing in another input', () => {
377
+ render(
378
+ <ReqoreUIProvider>
379
+ <ReqoreLayoutContent>
380
+ <ReqoreContent>
381
+ <ReqoreInput focusRules={{ type: 'keypress', shortcut: 's' }} />
382
+ <ReqoreInput focusRules={{ type: 'auto' }} />
383
+ </ReqoreContent>
384
+ </ReqoreLayoutContent>
385
+ </ReqoreUIProvider>
386
+ );
387
+
388
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
389
+ expect(document.querySelectorAll('.reqore-input')[1]).toHaveFocus();
390
+
391
+ fireEvent.keyDown(document.querySelectorAll('.reqore-input')[1], {
392
+ key: 's',
393
+ });
394
+
395
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
396
+ expect(document.querySelectorAll('.reqore-input')[1]).toHaveFocus();
397
+ });
398
+
399
+ test('Readonly <Input /> does not get focused when shortcut is pressed', () => {
400
+ render(
401
+ <ReqoreUIProvider>
402
+ <ReqoreLayoutContent>
403
+ <ReqoreContent>
404
+ <ReqoreInput focusRules={{ type: 'keypress', shortcut: 'letters' }} readOnly />
405
+ </ReqoreContent>
406
+ </ReqoreLayoutContent>
407
+ </ReqoreUIProvider>
408
+ );
409
+
410
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
411
+
412
+ fireEvent.keyDown(document, {
413
+ key: 'q',
414
+ });
415
+
416
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
417
+ });
418
+
419
+ test('Disabled <Input /> does not get focused when shortcut is pressed', () => {
420
+ render(
421
+ <ReqoreUIProvider>
422
+ <ReqoreLayoutContent>
423
+ <ReqoreContent>
424
+ <ReqoreInput focusRules={{ type: 'keypress', shortcut: 'numbers' }} readOnly />
425
+ </ReqoreContent>
426
+ </ReqoreLayoutContent>
427
+ </ReqoreUIProvider>
428
+ );
429
+
430
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
431
+
432
+ fireEvent.keyDown(document, {
433
+ key: '8',
434
+ });
435
+
436
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
437
+ });
438
+
439
+ test('<Input /> is cleared when focused', () => {
440
+ const fn = jest.fn();
441
+
442
+ render(
443
+ <ReqoreUIProvider>
444
+ <ReqoreLayoutContent>
445
+ <ReqoreContent>
446
+ <ReqoreInput
447
+ focusRules={{ type: 'keypress', shortcut: 'letters', clearOnFocus: true }}
448
+ value='this is a test'
449
+ onChange={fn}
450
+ />
451
+ </ReqoreContent>
452
+ </ReqoreLayoutContent>
453
+ </ReqoreUIProvider>
454
+ );
455
+
456
+ expect(document.querySelectorAll('.reqore-input')[0]).not.toHaveFocus();
457
+
458
+ fireEvent.keyDown(document, {
459
+ key: 'h',
460
+ });
461
+
462
+ expect(fn).toHaveBeenNthCalledWith(1, { target: { value: '' } });
463
+ expect(document.querySelectorAll('.reqore-input')[0]).toHaveFocus();
71
464
  });
@@ -40,8 +40,6 @@ test('Renders empty <ReqoreMultiSelect />', () => {
40
40
  expect(screen.getByText('No items selected')).toBeTruthy();
41
41
  expect(document.querySelectorAll('.reqore-input')?.length).toBe(1);
42
42
  expect(document.querySelector('.reqore-input')?.getAttribute('disabled')).toBe(null);
43
- // Because input is clearable
44
- expect(document.querySelectorAll('.reqore-button').length).toBe(1);
45
43
  expect(document.querySelectorAll('.reqore-popover-content').length).toBe(0);
46
44
  // No items tag
47
45
  expect(document.querySelectorAll('.reqore-tag').length).toBe(1);
@@ -149,13 +147,13 @@ test('Renders <ReqoreMultiSelect /> and items can be searched, opens up the list
149
147
 
150
148
  expect(document.querySelectorAll('.reqore-popover-content').length).toBe(1);
151
149
  // 4 items + 1 button for clearable input
152
- expect(document.querySelectorAll('.reqore-button').length).toBe(5);
150
+ expect(document.querySelectorAll('.reqore-button').length).toBe(4);
153
151
 
154
152
  fireEvent.change(document.querySelector('.reqore-input')!, {
155
153
  target: { value: 'Nothing' },
156
154
  });
157
155
 
158
- expect(document.querySelectorAll('.reqore-button').length).toBe(2);
156
+ expect(document.querySelectorAll('.reqore-button').length).toBe(1);
159
157
  expect(screen.getAllByText('No existing items found')).toBeTruthy();
160
158
  });
161
159
 
@@ -174,13 +172,13 @@ test('Renders <ReqoreMultiSelect /> and items can be searched and created, opens
174
172
 
175
173
  expect(document.querySelectorAll('.reqore-popover-content').length).toBe(1);
176
174
  // 4 items + 1 button for clearable input
177
- expect(document.querySelectorAll('.reqore-button').length).toBe(2);
175
+ expect(document.querySelectorAll('.reqore-button').length).toBe(1);
178
176
 
179
177
  fireEvent.change(document.querySelector('.reqore-input')!, {
180
178
  target: { value: 'Existing item' },
181
179
  });
182
180
 
183
- expect(document.querySelectorAll('.reqore-button').length).toBe(6);
181
+ expect(document.querySelectorAll('.reqore-button').length).toBe(5);
184
182
  expect(screen.getAllByText('Create new "Existing item"')).toBeTruthy();
185
183
 
186
184
  // This has to fail because we do not allow creating items with ENTER key
@@ -201,7 +199,7 @@ test('Renders <ReqoreMultiSelect /> and items can be searched and created, opens
201
199
  });
202
200
 
203
201
  // 6 again because the item is already created, so the Create button is not there
204
- expect(document.querySelectorAll('.reqore-button').length).toBe(6);
202
+ expect(document.querySelectorAll('.reqore-button').length).toBe(5);
205
203
  });
206
204
 
207
205
  test('Renders <ReqoreMultiSelect /> and items can be searched and created using the ENTER key, opens up the list', () => {
@@ -221,14 +219,14 @@ test('Renders <ReqoreMultiSelect /> and items can be searched and created using
221
219
 
222
220
  expect(document.querySelectorAll('.reqore-popover-content').length).toBe(1);
223
221
  // 4 items + 1 button for clearable input
224
- expect(document.querySelectorAll('.reqore-button').length).toBe(2);
222
+ expect(document.querySelectorAll('.reqore-button').length).toBe(1);
225
223
 
226
224
  fireEvent.focus(document.querySelector('.reqore-input')!);
227
225
  fireEvent.change(document.querySelector('.reqore-input')!, {
228
226
  target: { value: 'Existing item' },
229
227
  });
230
228
 
231
- expect(document.querySelectorAll('.reqore-button').length).toBe(6);
229
+ expect(document.querySelectorAll('.reqore-button').length).toBe(5);
232
230
  expect(screen.getAllByText('Create new "Existing item"')).toBeTruthy();
233
231
 
234
232
  // Create the item by pressing ENTER key
@@ -245,7 +243,7 @@ test('Renders <ReqoreMultiSelect /> and items can be searched and created using
245
243
  });
246
244
 
247
245
  // 6 again because the item is already created, so the Create button is not there
248
- expect(document.querySelectorAll('.reqore-button').length).toBe(6);
246
+ expect(document.querySelectorAll('.reqore-button').length).toBe(5);
249
247
 
250
248
  fireEvent.focus(document.querySelector('.reqore-input')!);
251
249
  // Does not create new item if the query is empty