Testing material-ui's SelectField with jest

Viewed 315

I am trying to figure out the proper way of testing material-ui's SelectField component with jest. I need to simulate change with certain parameters. What I have for now:

it('when SelectField with id city_id changed, onFilterChanged prop should be called', () => {
  const SelectField = form.findWhere(n => n.props().id === 'city_id' && n.name() === 'SelectField').find('[type="button"]')
  const spy = jest.spyOn(defaultProps, 'onFilterChanged')

  SelectField.simulate('change')

  expect(spy).toBeCalled()
})

It's supposed to find a button inside SelectField and click it. My question is how to simulate change on SelectField with certain parameters?

0 Answers
Related