...

/

Testing Async Middleware

Testing Async Middleware

Let’s see how we can test async middleware.

We'll cover the following...

For a more complete example, let’s use the following API middleware:

import axios from 'axios';
import { API } from 'consts';
import { apiStarted, apiFinished, apiError } from 'actions/ui';

const apiMiddleware = ({ dispatch, getState }) => next => action => {
  if (action.type !== API) {
    return next(action);
  }

  const { url, success } = action.payload;
  const headers = {};
  const accessToken =
...