action异步单元测试

export const setFetchStatus = (status: FETCH_STATUS): Action.SetHomeFetchStatus => ({
  type: Action.SET_HOME_FETCH_STATUS,
  payload: status,
});

export const setBaseInfo = (data: HomeBaseInfo): Action.SetHomeBaseInfo => ({
  type: Action.SET_HOME_BASE_INFO,
  payload: data,
});

export const getBaseInfo = () => (dispatch: Dispatch): void => {
  dispatch(setFetchStatus(FETCH_STATUS.LOADING));
  get<HomeBaseInfo>(API_SHOP_HOME)
    .then(res => {
      dispatch(setBaseInfo(res));
      dispatch(setFetchStatus(FETCH_STATUS.SUCCESS));
    })
    .catch(() => {
      dispatch(setFetchStatus(FETCH_STATUS.FAILURE));
    });
};

求助大佬 这种redux的action axios异步单元测试要如何去写

阅读 144
评论
    0 个回答
    撰写回答

    登录后参与交流、获取后续更新提醒

    相似问题
    推荐文章