import React from 'react';
import { shallow } from 'enzyme';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import reducer from '../redux/reducers';

const renderConnected = (
  ui,
  { initialState = {}, store = createStore(reducer, initialState), ...renderOptions } = {}
) => {
  const Wrapper = ({ children }) => <Provider store={store}>{children}</Provider>;
  return shallow(ui, { wrapper: Wrapper, ...renderOptions });
};

export default renderConnected;
