My component has a method ..
onUpdateProperty = (key, value) => {
this.state.formData[key] = value;
}
I want to test if after change input, this method is called...
it('on update input should update formData', function () {
const wrapper = mount(<MyComp.wrappedComponent {...this.minProps} />);
const spy = spyOn(wrapper.instance(), 'onUpdateProperty');
expect(spy).not.toHaveBeenCalled();
const nameInput = wrapper.find('[name="name"]');
nameInput.simulate('change', {
target: { name: 'name', value: 'v1' },
});
wrapper.update();
// expect(spy).toHaveBeenCalledWith('name', 'v1');
expect(spy).toHaveBeenCalled();
});
wrappedComponent is because I use Mobx-react