n = int(input("set range:- "))
父组件
I want to mock get Token inside the mocked function in test case by calling from the child component
CHild组件
onLocationSubmit = async (start, end) => {
try {
this.setState({ token: false, isLoader: true, errorMessage: "", routeDetail: {}, path: [] });
const response = await getToken({ start, end });
if (response && response.data && response.data.token) {
this.setState({ token: response.data.token }, () => {
this.getDirectionPath();
});
}
} catch (error) {
this.setState({ errorMessage: error.response.data, isLoader: false });
}
};
模拟提交功能
const mockSubmit = jest.fn()。mockReturnValue(1);