Drying up DOM events
There's still more that we can do. Those ReactTestUtils.Simulate.* calls can be shortened and made a little easier to read.
If you do a search in the code base for these calls (for example, by running git grep ReactTestUtils.Simulate on the command line), you'll see that we use three functions on the Simulate object: click, change, and submit. We can deal with these by adding new properties onto the returned value from createContainer.
The first two functions, click and change, will be simple pass-throughs to the ReactTestUtils.Simulate call of the same name. We'll pull out a helper function, named simulateEvent, that we can re-use for each of the events.
The third function, submit, needs a little extra work. All our ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access