diff --git a/src/redux/modules/counter.js b/src/redux/modules/counter.js index a99563b70..4c7f2fc12 100644 --- a/src/redux/modules/counter.js +++ b/src/redux/modules/counter.js @@ -21,7 +21,7 @@ export const doubleAsync = () => { return (dispatch, getState) => { return new Promise((resolve) => { setTimeout(() => { - dispatch(increment(getState().counter)); + dispatch(increment(getState().get('counter'))); resolve(); }, 200); }); diff --git a/tests/redux/modules/counter.spec.js b/tests/redux/modules/counter.spec.js index b592037ff..5807651c4 100644 --- a/tests/redux/modules/counter.spec.js +++ b/tests/redux/modules/counter.spec.js @@ -1,3 +1,4 @@ +import { Map } from 'immutable'; import { COUNTER_INCREMENT, increment, @@ -55,14 +56,14 @@ describe('(Redux Module) Counter', function () { let _getStateSpy; beforeEach(function () { - _globalState = { + _globalState = new Map(); + _globalState = _globalState.merge({ counter: counterReducer(undefined, {}) - }; + }); _dispatchSpy = sinon.spy((action) => { - _globalState = { - ..._globalState, - counter: counterReducer(_globalState.counter, action) - }; + _globalState = _globalState.merge({ + counter: counterReducer(_globalState.get('counter'), action) + }); }); _getStateSpy = sinon.spy(() => { return _globalState; @@ -90,19 +91,19 @@ describe('(Redux Module) Counter', function () { }); it('Should produce a state that is double the previous state.', function () { - _globalState = { counter: 2 }; + _globalState = _globalState.merge({ counter: 2 }); return doubleAsync()(_dispatchSpy, _getStateSpy) .then(() => { _dispatchSpy.should.have.been.calledOnce; _getStateSpy.should.have.been.calledOnce; - expect(_globalState.counter).to.equal(4); + expect(_globalState.get('counter')).to.equal(4); return doubleAsync()(_dispatchSpy, _getStateSpy); }) .then(() => { _dispatchSpy.should.have.been.calledTwice; _getStateSpy.should.have.been.calledTwice; - expect(_globalState.counter).to.equal(8); + expect(_globalState.get('counter')).to.equal(8); }); }); });