@@ -334,9 +334,11 @@ _./src/common/components/search-bar/search-bar.component.tsx_
334
334
value={search}
335
335
onChange={e => onSearch(e.target.value)}
336
336
placeholder={labels.placeholder}
337
- InputProps={{
338
- - startAdornment: <SearchIcon />,
339
- + startAdornment: <SearchIcon aria-label="Search icon" />,
337
+ slotProps={{
338
+ input: {
339
+ - startAdornment: <SearchIcon />,
340
+ + startAdornment: <SearchIcon aria-label="Search icon" />,
341
+ },
340
342
}}
341
343
/>
342
344
);
@@ -512,13 +514,13 @@ import { useSearchBar } from './search-bar.hook';
512
514
+ { id: 2, name: 'blue' },
513
515
+ { id: 3, name: 'green' },
514
516
+ ];
515
- + const debounceSearchStub = vi.spyOn(commonHooks, 'useDebounce');
517
+ + vi.spyOn(commonHooks, 'useDebounce');
516
518
517
519
+ // Act
518
520
+ renderHook(() => useSearchBar(colors, ['name']));
519
521
520
522
+ // Assert
521
- + expect(debounceSearchStub ).toHaveBeenCalledWith('', 250);
523
+ + expect(commonHooks.useDebounce ).toHaveBeenCalledWith('', 250);
522
524
+ });
523
525
524
526
```
@@ -537,15 +539,13 @@ _./src/common/components/search-bar/search-bar.hook.spec.tsx_
537
539
+ { id: 2, name: 'blue' },
538
540
+ { id: 3, name: 'green' },
539
541
+ ];
540
- + const debounceSearchStub = vi
541
- + .spyOn(commonHooks, 'useDebounce')
542
- + .mockReturnValue('blue');
542
+ + vi.spyOn(commonHooks, 'useDebounce').mockReturnValue('blue');
543
543
544
544
+ // Act
545
545
+ const { result } = renderHook(() => useSearchBar(colors, ['name']));
546
546
547
547
+ // Assert
548
- + expect(debounceSearchStub ).toHaveBeenCalledWith('', 250);
548
+ + expect(commonHooks.useDebounce ).toHaveBeenCalledWith('', 250);
549
549
+ expect(result.current.search).toEqual('');
550
550
+ expect(result.current.filteredList).toEqual([{ id: 2, name: 'blue' }]);
551
551
+ });
@@ -570,13 +570,13 @@ import { useSearchBar } from './search-bar.hook';
570
570
+ { id: 2, name: 'blue' },
571
571
+ { id: 3, name: 'green' },
572
572
+ ];
573
- + const filterByTextStub = vi.spyOn(filterHelpers, 'filterByText');
573
+ + vi.spyOn(filterHelpers, 'filterByText');
574
574
575
575
+ // Act
576
576
+ renderHook(() => useSearchBar(colors, ['name']));
577
577
578
578
+ // Assert
579
- + expect(filterByTextStub ).toHaveBeenCalledWith(colors, '', ['name']);
579
+ + expect(filterHelpers.filterByText ).toHaveBeenCalledWith(colors, '', ['name']);
580
580
+ });
581
581
582
582
```
@@ -595,18 +595,18 @@ _./src/common/components/search-bar/search-bar.hook.spec.tsx_
595
595
+ { id: 2, name: 'blue' },
596
596
+ { id: 3, name: 'green' },
597
597
+ ];
598
- + const filterByTextStub = vi
599
- + .spyOn(filterHelpers, 'filterByText')
600
- + .mockReturnValue([
601
- + { id: 2, name: 'blue' },
602
- + { id: 3, name: 'green' },
603
- + ]);
598
+ + vi.spyOn(filterHelpers, 'filterByText').mockReturnValue([
599
+ + { id: 2, name: 'blue' },
600
+ + { id: 3, name: 'green' },
601
+ + ]);
604
602
605
603
+ // Act
606
604
+ const { result } = renderHook(() => useSearchBar(colors, ['name']));
607
605
608
606
+ // Assert
609
- + expect(filterByTextStub).toHaveBeenCalledWith(colors, '', ['name']);
607
+ + expect(filterHelpers.filterByText).toHaveBeenCalledWith(colors, '', [
608
+ + 'name',
609
+ + ]);
610
610
+ expect(result.current.search).toEqual('');
611
611
+ expect(result.current.filteredList).toEqual([
612
612
+ { id: 2, name: 'blue' },
0 commit comments