jeudi 29 septembre 2016

Using Enzyme simulate on custom events?

It is possible to use Enzyme's method .simulate() on custom events. For Example:

// Code
<Element onFoo={someFunction}></Elements>

// Test
const element = shallow(<Element>);
element.simulate('foo');

Is this the way custom events should be tested with Enzyme or is it a better approach to use s.th. like:

//Test
const element = shallow(<Element>);
element.props.onFoo()

Aucun commentaire:

Enregistrer un commentaire