diff options
Diffstat (limited to 'spec/javascripts')
| -rw-r--r-- | spec/javascripts/vehicle_journeys/reducers/modal_spec.js | 44 | ||||
| -rw-r--r-- | spec/javascripts/vehicle_journeys/reducers/pagination_spec.js | 17 |
2 files changed, 61 insertions, 0 deletions
diff --git a/spec/javascripts/vehicle_journeys/reducers/modal_spec.js b/spec/javascripts/vehicle_journeys/reducers/modal_spec.js new file mode 100644 index 000000000..8da8e6c65 --- /dev/null +++ b/spec/javascripts/vehicle_journeys/reducers/modal_spec.js @@ -0,0 +1,44 @@ +var modalReducer = require('es6_browserified/vehicle_journeys/reducers/modal') + +let state = {} + +const cb = function(){} + +describe('modal reducer', () => { + beforeEach(() => { + state = { + type: '', + modalProps: {}, + confirmModal: {} + } + }) + + it('should return the initial state', () => { + expect( + modalReducer(undefined, {}) + ).toEqual({}) + }) + + it('should handle OPEN_CONFIRM_MODAL', () => { + let newState = Object.assign({}, state, { + type: 'confirm', + confirmModal: { + callback: cb + } + }) + expect( + modalReducer(state, { + type: 'OPEN_CONFIRM_MODAL', + callback: cb + }) + ).toEqual(newState) + }) + + it('should handle CLOSE_MODAL', () => { + expect( + modalReducer(state, { + type: 'CLOSE_MODAL' + }) + ).toEqual(state) + }) +}) diff --git a/spec/javascripts/vehicle_journeys/reducers/pagination_spec.js b/spec/javascripts/vehicle_journeys/reducers/pagination_spec.js index 240d99c85..2dd600436 100644 --- a/spec/javascripts/vehicle_journeys/reducers/pagination_spec.js +++ b/spec/javascripts/vehicle_journeys/reducers/pagination_spec.js @@ -39,6 +39,23 @@ describe('pagination reducer, given parameters allowing page change', () => { }) ).toEqual(Object.assign({}, state, {page : state.page - 1, stateChanged: false})) }) + + it('should handle UPDATE_TIME', () => { + const val = '33', subIndex = 0, index = 0, timeUnit = 'minute', isDeparture = true, isArrivalsToggled = true + expect( + reducer(state, { + type: 'UPDATE_TIME', + val, + subIndex, + index, + timeUnit, + isDeparture, + isArrivalsToggled + }) + ).toEqual(Object.assign({}, state, {stateChanged: true}) +) + }) + }) |
