mercredi 26 août 2015

Jasmine: How to test a function which returns another function?

Question says it all. Given this function:

export function fetchBuilds() {
  return dispatch => {
    touchCookie();
    dispatch(requestBuilds());
    return request.get('/builds')
      .withCredentials()
      .use(AuthIntercept)
      .then((response) => {
        dispatch(receiveBuilds(response));
      }, (error) => {
        dispatch(receiveBuildsError(error.message));
      });
  };
}

what's the most effective testing strategy? I plan on mocking the AJAX request, but how do I assert that the return is what I expect?

Following on the heels of that, I'm also at a loss as to the best way to test the control flow for the function; or is that even something I should worry about?

Aucun commentaire:

Enregistrer un commentaire