diff --git a/test/middleware.spec.js b/test/middleware.spec.js index c49eddb0..1e4b6209 100644 --- a/test/middleware.spec.js +++ b/test/middleware.spec.js @@ -10,6 +10,24 @@ import { chai.use(sinonChai); +const REFRAGULATE = 'REFRAGULATE'; + +// Used to test that other middleware can dispatch +// router actions and trigger history updates +const consumerMiddleware = ({ dispatch }) => next => action => { + if (action.type === REFRAGULATE) { + dispatch({ + type: PUSH, + payload: { + pathname: '/' + } + }); + return; + } + + next(action); +}; + const init = () => { const historyStub = { push: sandbox.stub(), @@ -25,7 +43,8 @@ const init = () => { applyMiddleware( routerMiddleware({ history: historyStub - }) + }), + consumerMiddleware ) ); @@ -67,4 +86,14 @@ describe('Router middleware', () => { expect(historyStub[method]).to.not.have.been.called; }); }); + + it('passes normal actions through the dispatch chain', () => { + const { store, historyStub } = init(); + store.dispatch({ + type: REFRAGULATE, + payload: {} + }); + + expect(historyStub.push).to.have.been.called.once; + }); }); diff --git a/test/store-enhancer.spec.js b/test/store-enhancer.spec.js index 5e00cd24..38fe47a9 100644 --- a/test/store-enhancer.spec.js +++ b/test/store-enhancer.spec.js @@ -5,8 +5,7 @@ import { compose, createStore, applyMiddleware } from 'redux'; import { install, combineReducers } from 'redux-loop'; import { - LOCATION_CHANGED, PUSH, REPLACE, - GO, GO_BACK, GO_FORWARD + LOCATION_CHANGED, PUSH } from '../src/action-types'; import createStoreWithRouter from '../src/store-enhancer';