From 69495e859893db0d3d75fbac23ac346a8bdc7eec Mon Sep 17 00:00:00 2001 From: Thomas Haddad Date: Thu, 16 Feb 2017 11:56:46 +0100 Subject: Refs #2521: Add confirm modal when changing page if modifications were previously done Signed-off-by: Thomas Shawarma Haddad --- .../vehicle_journeys/reducers/modal_spec.js | 44 ++++++++++++++++++++++ .../vehicle_journeys/reducers/pagination_spec.js | 17 +++++++++ 2 files changed, 61 insertions(+) create mode 100644 spec/javascripts/vehicle_journeys/reducers/modal_spec.js (limited to 'spec/javascripts') 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}) +) + }) + }) -- cgit v1.2.3