Skip to content

Commit

Permalink
test: fix after review
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosvega91 committed Jun 21, 2020
1 parent 7cdce7f commit 01bd560
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/__tests__/select-options.js
Expand Up @@ -140,20 +140,22 @@ test('should call onChange/input bubbling up the event when a new option is sele
const onChangeForm = jest.fn()
const onInputSelect = jest.fn()
const onInputForm = jest.fn()
select.addEventListener('change', onChangeSelect)
select.addEventListener('input', onInputSelect)
form.addEventListener('change', onChangeForm)
form.addEventListener('input', onInputForm)
addListeners(select, {
eventHandlers: {change: onChangeSelect, input: onInputSelect},
})
addListeners(form, {
eventHandlers: {change: onChangeForm, input: onInputForm},
})

expect(onChangeSelect.mock.calls).toHaveLength(0)
expect(onChangeForm.mock.calls).toHaveLength(0)
expect(onInputSelect.mock.calls).toHaveLength(0)
expect(onInputForm.mock.calls).toHaveLength(0)
expect(onChangeSelect).toHaveBeenCalledTimes(0)
expect(onChangeForm).toHaveBeenCalledTimes(0)
expect(onInputSelect).toHaveBeenCalledTimes(0)
expect(onInputForm).toHaveBeenCalledTimes(0)

userEvent.selectOptions(select, ['1'])

expect(onChangeForm.mock.calls).toHaveLength(1)
expect(onChangeSelect.mock.calls).toHaveLength(1)
expect(onInputSelect.mock.calls).toHaveLength(1)
expect(onInputForm.mock.calls).toHaveLength(1)
expect(onChangeForm).toHaveBeenCalledTimes(1)
expect(onChangeSelect).toHaveBeenCalledTimes(1)
expect(onInputSelect).toHaveBeenCalledTimes(1)
expect(onInputForm).toHaveBeenCalledTimes(1)
})

0 comments on commit 01bd560

Please sign in to comment.