'Test async thunk with jest mock

Maybe someone can help me write test? This theme is difficult for me, i'll hope somebody explain that.

  return axios.post("http://localhost:5000/login", {
    login,
    password,
  });
};
export const loginThunk = (login, password) => (dispatch) => {
  dispatch(fetchingAction(true));
  fakeLoginRequest(login, password)
    .then((response) => {
      dispatch(fetchingAction(false));
      if (response.data.isLoggedIn) {
        dispatch(loginAction(login, password, response.data.isLoggedIn));
      } else {
        alert("Wrong login or password");
      }
    })
    .catch((error) => {
      dispatch(fetchingAction(false));
      alert("cannot connect to server");
      console.log(error);
    });
};```


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source