Open NilapuAnusha opened 6 years ago
Hi, I am writing testcases using enzyme, mocha and chai. When I call onChange event for multiselect it is not firing call.
Here is my code:
First one
it('change country selection', () => { const wrapper = mount(<SearchFormPanel {...props}/>) const onCountryChange = spy(wrapper.instance(), 'onCountryChange') wrapper.instance().forceUpdate() wrapper.find('input[type="checkbox"]') expect(onCountryChange).to.have.calledOnce expect(wrapper.state('selectedCountries')).to.contain('GB') onCountryChange.restore() })
Second one
it('change country selection', () => { const wrapper = mount(<SearchFormPanel {...props}/>) const onCountryChange = spy(wrapper.instance(), 'onCountryChange') wrapper.instance().forceUpdate() let checkboxNode = $($(wrapper.getDOMNode()).find('input[type="checkbox"]')[3]) checkboxNode.prop('checked', true).change() expect(onCountryChange).to.have.calledOnce expect(wrapper.state('selectedCountries')).to.contain('GB') onCountryChange.restore() })
Is there any better way to find onChange event?
Hi, I am writing testcases using enzyme, mocha and chai. When I call onChange event for multiselect it is not firing call.
Here is my code:
Is there any better way to find onChange event?