So I'm trying to test some functionality that is based on the material-ui toggle component, using jest and enzyme.
I have a generic clickIt function that works well for other material-ui components, but in this one it doesn't seem to be triggering the state change
function clickIt(wrapper, selector) {
let elem = wrapper;
if (selector) {
elem = wrapper.find(selector);
}
const node = ReactDOM.findDOMNode(elem.node);
TestUtils.Simulate.touchTap(node);
}
And on the test:
const toggle = wrapper.find('#subscribe-toggle');
expect(toggle.props().checked).to.be(true);
clickIt(toggle);
expect(toggle.props().checked).to.be(true); // <- fails
Any idea on how to solve this?