[SOLVED]-HOW CAN I TEST REACT TOGGLE WITH JEST+ENZYME?-REACTJS
HOW CAN I TEST REACT TOGGLE WITH JEST+ENZYME?-REACTJS
it’s generally better, especially in stateless components, not to test the implementation, but its result.
it('user click button', () => {
expect(wrapper.find(reactmardown)).tohavelength(0);
wrapper.find('#button').simulate('click');
expect(wrapper.find(reactmardown)).tohavelength(1);
});
@nambk i’d go with testing the style, eg. some component’s background-color
:
expect(component.find('#item-id').prop('style')).tohaveproperty('backgroundcolor' 'black');