Skip to content

Commit

Permalink
broken test adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrevmatias committed Sep 23, 2024
1 parent 7ffa763 commit 0152abb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
37 changes: 22 additions & 15 deletions src/components/Combobox/ComboboxMultiselect.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<ComboboxTest />)
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(<ComboboxTest clearFilterOnSelect={clearFilterOnSelect} />)
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(<ComboboxTest clearFilterOnSelect={true} />)
Expand Down
4 changes: 1 addition & 3 deletions src/components/Combobox/ComboboxMultiselect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,7 @@ function comboboxMultiselectStateReducer<T>(
case useCombobox.stateChangeTypes.InputBlur:
return {
...changes,
...(!changes.selectedItem && {
inputValue: '',
}),
inputValue: '',
}
default:
return changes
Expand Down

0 comments on commit 0152abb

Please sign in to comment.