开玩笑+酶测试异步功能

时间:2019-03-27 10:50:27

标签: jest-fetch-mock

我无法编写异步api的测试用例

我尝试使用mockAxios

export const exportAllCustomers = ({ token, start_date, end_date }) => {
  var url = getExportUrl({start_date, end_date})
  console.log("start_date ", start_date)
  console.log("in export data ", url)
  return (dispatch) => new Promise(async (resolve, reject) => {
    dispatch(showLoading())
    axios.get(API_ENDPOINT +url,{
      headers: {
        Authorization: 'Token ' + token,
      }
      })
      .then((response) => {
      dispatch(hideLoading())
        return resolve (response.data);
      })
    .catch((error) => {
      dispatch(hideLoading())
      return reject ("error: ");
    });

期望值是客户列表,但没有得到。

0 个答案:

没有答案