From 0152abb227f8040bcf1f7637752b6de9c28dbb7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Vict=C3=B3ria=20Matias?= Date: Mon, 23 Sep 2024 09:59:24 -0300 Subject: [PATCH] broken test adjustment --- .../Combobox/ComboboxMultiselect.test.tsx | 37 +++++++++++-------- .../Combobox/ComboboxMultiselect.tsx | 4 +- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/components/Combobox/ComboboxMultiselect.test.tsx b/src/components/Combobox/ComboboxMultiselect.test.tsx index c21edc13d..17fabcdc6 100644 --- a/src/components/Combobox/ComboboxMultiselect.test.tsx +++ b/src/components/Combobox/ComboboxMultiselect.test.tsx @@ -544,21 +544,28 @@ describe('async loading', () => { }) describe('filtering', () => { - it('should clear the current filter and the input value after menu is closed', async () => { - const { container } = render() - const input = container.querySelector('input')! - - fireEvent.focus(input) - fireEvent.change(input, { target: { value: 'pe' } }) - - await waitFor(() => expect(container.querySelectorAll('li')).toHaveLength(4)) - - fireEvent.click(container.querySelectorAll('li')[0]) - fireEvent.blur(input) - - expect(container.querySelectorAll('li')).toHaveLength(0) - expect(input.value).toEqual('') - }) + test.each` + clearFilterOnSelect + ${true} + ${false} + `( + 'should clear the current filter and the input value after menu is closed (clearFilterOnSelect: $clearFilterOnSelect)', + async ({ clearFilterOnSelect }) => { + const { container } = render() + const input = container.querySelector('input')! + + fireEvent.focus(input) + fireEvent.change(input, { target: { value: 'pe' } }) + + await waitFor(() => expect(container.querySelectorAll('li')).toHaveLength(4)) + + fireEvent.click(container.querySelectorAll('li')[0]) + fireEvent.blur(input) + + expect(container.querySelectorAll('li')).toHaveLength(0) + expect(input.value).toEqual('') + } + ) it('should clear the current filter and the input value after an item is selected if clearFilterOnSelect is true', async () => { const { container } = render() diff --git a/src/components/Combobox/ComboboxMultiselect.tsx b/src/components/Combobox/ComboboxMultiselect.tsx index bde1a7e2e..4fdc0d9c4 100644 --- a/src/components/Combobox/ComboboxMultiselect.tsx +++ b/src/components/Combobox/ComboboxMultiselect.tsx @@ -280,9 +280,7 @@ function comboboxMultiselectStateReducer( case useCombobox.stateChangeTypes.InputBlur: return { ...changes, - ...(!changes.selectedItem && { - inputValue: '', - }), + inputValue: '', } default: return changes