I’m trying to do some TDD with Elm. To test events, I do something like this:
|> Query.find [ Selector.id “someId” ]
|> Event.simulate Event.click
|> Event.expect SomeEvent
That works fine to simulate a click. But I can’t figure out how to test a html Select/option.
What I want to test: when user selects the last option from a select, should dispatch a specific message with a specific value.
In selects you get an input event as if the user had typed something. If you want to know which is the selected option you will have write an event decoder that checks for all the options to see if the selected one is the last one, or simply make a decoder that in case of a select returns index of the selected option and the option count.
Keep in mind that the options of a select have very different implementation in mobile than in the browser, so I don’t recommend looking at them as regular HTML entities.