Answer the question
In order to leave comments, you need to log in
How to test a function with another function from Redux inside using Jest?
I started to study tests and stuck at this point
There is a function:
private handleCountyItemClick = (
e: React.FormEvent<HTMLButtonElement>
): void => {
const { countries } = this.props.countriesRed;
const selectedId: number = parseFloat(e.currentTarget.dataset.value);
const foundCountry = countries.find(
(country: Country, i: number) => i === selectedId
);
if (foundCountry) {
this.props.CountyItemClick(foundCountry);
this.props.clearInput();
this.setState({
dropdownOpen: false,
fullWidthFullHeightElHeight: 54
});
this.countriesListItems.current.style.height = "";
scrollIt(this.props.countriesRootEl.current, 300, "easeOutQuad", () =>
enableBodyScroll(this.countriesListItems.current)
);
}
};
it("should update the count by 1 when invoked by default", () => {
const wrapper = shallow(component);
const instance = wrapper.instance();
instance.handleCountyItemClick({
currentTarget: { dataset: { value: 1 } }
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question