mardi 1 mars 2016

React unit tests - How to simulate checkbox checked

I've simple html checkbox and trying to simulate the checked event.

This one works

`checkbox.checked="true";`

This one doesn't work

`TestUtils.Simulate.change(checkbox,{target:{checked:true}});`

Incase of controlled component input text box, textbox.value='test' will not simulate the user behavior. Rather TestUtils.Simulate.change(inputField,{target:{value:'sahas'}}); does a great job. Similarly, wondering whats the right approach with checkbox..

Aucun commentaire:

Enregistrer un commentaire