import React from 'react';
import mount from 'enzyme/mount';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
const mockStore = configureStore();

/**
 * Helper function to check the prop mappings in a connected component
 * It mounts the given component with the given state
 * @param Component
 * @param state
 * @param props
 * @returns {{store, wrapper: *}}
 */
export default function(Component, state = {}, props = {}) {
    const store = mockStore(state);
    store.dispatch = jest.fn();
    const wrapper = mount(
        <Provider store={store}>
            <Component {...props} />
        </Provider>
    );
    return {
        store,
        wrapper,
    };
}
