How to test a situation where user selects option from data list?
I have tried:
it('should trigger onChange with selected option', () => {
const onChange = jest.fn()
const screen = render(<MyInput onChange={onChange} list={list} />)
userEvent.selectOptions(screen.getByLabelText('datalist-items'), 'first')
expect(onChange).toHaveBeenCalledWith('first')
})
However that does not work. The component <datalist> DOM node has aria-label=datalist-items.
Aucun commentaire:
Enregistrer un commentaire