1.0.0 • Published 3 years ago

redux-mock-store-tuner v1.0.0

Weekly downloads
6
License
ISC
Repository
github
Last release
3 years ago

redux-mock-store-tuner

This is just wrapper of the redux-mock-store that allows you to update current Redux store of your application to let your testing React-component get appropriate state of storage. Be aware that the package needs TypeScript version not less than 4.1.3, because only from that version TypeScript provides ability of recursive types inferring.

Installation

npm i redux-mock-store-tuner -D

Usage

Javascript or TypeScript

import store from './path_of_your_app_store';
import ReduxStoreMocker from 'redux-mock-store-tuner';

const mockStore = new ReduxStoreMocker(store.getState());
const updatedStore = mockStore.updateMockStore([
  ['house', 'new'],
  ['numberOfFloor', 2],
  ['soft', false],
  ['color', 'white'],
]);

// than your can pass the store to the Provider in tests
const wrapper = mount(
  <Provider store={updatedStore}>
    <Router>
      <TestingComponent />
    </Router>
  </Provider>
);