export function createStore(initialState) { const store = configureStore({ reducer: rootReducer, preloadedState: initialState, }); if (process.env.NODE_ENV === 'development' && module.hot) { module.hot.accept('./rootReducer', () => { const newRootReducer = require('./rootReducer').default; store.replaceReducer(newRootReducer); }); } return store; }
describe('configureStore', () => { it('should return a store with injected enhancers', () => { const store = configureAppStore(); expect(store).toEqual( expect.objectContaining({ runSaga: expect.any(Function), injectedReducers: expect.any(Object), injectedSagas: expect.any(Object), }), ); }); it('should return an empty store', () => { const store = configureAppStore(); expect(store.getState()).toBeUndefined(); }); });
export default function initStore(preloadedState) { const reducer = combineReducers({ api: apiReducer, app: appReducer }); const store = configureStore({ reducer, middleware: [...getDefaultMiddleware()], preloadedState }); if (process.env.NODE_ENV !== 'production' && module.hot) { module.hot.accept('../api/reducer', () => store.replaceReducer(reducer)); } return store; }
describe('configureStore', () => { it('should return a store with injected enhancers', () => { const store = configureAppStore(); expect(store).toEqual( expect.objectContaining({ runSaga: expect.any(Function), injectedReducers: expect.any(Object), injectedSagas: expect.any(Object), }), ); expect(store.getState().router).toBeDefined(); }); it('should return a store with router in state', () => { const store = configureAppStore(history); expect(store.getState().router).toBeDefined(); }); });
export default function initStore(preloadedState) { const reducer = combineReducers({ api: apiReducer, app: appReducer }); const store = configureStore({ reducer, middleware: [...getDefaultMiddleware()], preloadedState }); if (process.env.NODE_ENV !== 'production' && module.hot) { module.hot.accept('../api/reducer', () => store.replaceReducer(reducer)); } return store; }
describe('configureStore', () => { it('should return a store with injected enhancers', () => { const store = configureAppStore(); expect(store).toEqual( expect.objectContaining({ runSaga: expect.any(Function), injectedReducers: expect.any(Object), injectedSagas: expect.any(Object), }), ); }); it('should return an empty store', () => { const store = configureAppStore(); expect(store.getState()).toBeUndefined(); }); });
describe('configureStore', () => { it('should return a store with injected enhancers', () => { const store = configureAppStore(); expect(store).toEqual( expect.objectContaining({ runSaga: expect.any(Function), injectedReducers: expect.any(Object), injectedSagas: expect.any(Object), }), ); expect(store.getState().router).toBeDefined(); }); it('should return a store with router in state', () => { const store = configureAppStore(history); expect(store.getState().router).toBeDefined(); }); });