How to use the redux-mock-store.createStoreFromState function in redux-mock-store

To help you get started, we’ve selected a few redux-mock-store examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shakacode / reactrails-react-native-client / __tests__ / bundles / comments / thunks / createComment.js View on Github external
it('creates a comment in the store and sends request to api', async() => {
    const data = {
      commentsStore: {},
      commentForm: { author: 'Alexey', text: 'Random comment' },
    };
    const store = createStoreFromState(fromJS(data));
    const response = {
      entities: {
        comments: {
          1: { id: 1, author: 'Alexey', text: 'Random comment' },
        },
      },
    };
    mockCalls(null, response);
    await store.dispatch(actions.createComment());
    expect(store.getActions()).toMatchSnapshot();
  });
});
github shakacode / reactrails-react-native-client / __tests__ / bundles / comments / hocs / withAddProps.js View on Github external
it('adds AddProps to a component', () => {
    const state = initialState.mergeDeep({
      commentForm: {
        author: 'Alexey',
        text: 'Random comment',
      },
    });
    const store = createStoreFromState(state);
    const Component = withAddProps(Mock);
    const tree = renderer.create();
    expect(tree).toMatchSnapshot();
  });
});
github shakacode / reactrails-react-native-client / __tests__ / bundles / comments / hocs / withIndexProps.js View on Github external
it('adds props to Index component', () => {
    const state = initialState.mergeDeep({
      commentsStore: {
        2: { id: 2, author: 'Justin', text: 'Another random comment' },
        3: { id: 3, author: 'John', text: 'Yet another random comment' },
        1: { id: 1, author: 'Alexey', text: 'Just some random comment' },
      },
    });
    const store = createStoreFromState(state);
    const Component = withIndexProps(Mock);
    const tree = renderer.create();
    expect(tree).toMatchSnapshot();
  });
});

redux-mock-store

A mock store for testing your redux async action creators and middleware

MIT
Latest version published 18 days ago

Package Health Score

86 / 100
Full package analysis

Similar packages