0.1.1 • Published 8 years ago

redux-promise-mock v0.1.1

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

Redux-Promise-Mock

Middleware meant to be used with Redux Promise that can be used to mock remote API calls with mock data.

This middleware will automatically return mock data whenever the API promise-based request executed via redux-promise (https://github.com/acdlite/redux-promise) throws an error.

Basic Usage

Import createMockMiddleware wherever you create your Redux store middleware.

import { createMockMiddleware } from 'redux-promise-mock';

Call the createMockMiddleware, passing it an object where the keys match action types that will be dispatched to your Redux reducers where you wish to mock the data that's returned.

const mockData = createMockMiddleware({
  LOAD_CONTACT_DETAIL: {
    ID: 1,
    name: 'Eric',
    email: 'eric@email.com'
  },
  LOAD_CONTACT_LIST: [
    {
      ID: 1,
      name: 'Eric',
      email: 'eric@email.com'
    },
    {
      ID: 2,
      name: 'Hyun',
      email: 'hyun@email.com'
    }
  ]
});

Use Redux's applyMiddleware to attach your newly created mockData middleware.

applyMiddleware(ReduxPromise, mockData);
0.1.1

8 years ago

0.1.0

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago

1.0.0

8 years ago