diff options
Diffstat (limited to 'spec/javascripts')
3 files changed, 85 insertions, 0 deletions
diff --git a/spec/javascripts/vehicle_journeys/actions_spec.js b/spec/javascripts/vehicle_journeys/actions_spec.js index 5d01ac284..d2c95d4a1 100644 --- a/spec/javascripts/vehicle_journeys/actions_spec.js +++ b/spec/javascripts/vehicle_journeys/actions_spec.js @@ -152,3 +152,34 @@ describe('when clicking on validate button inside duplicating modal', () => { expect(actions.duplicateVehicleJourney(data)).toEqual(expectedAction) }) }) +describe('when clicking on edit notes modal', () => { + it('should create an action to open footnotes modal', () => { + const vehicleJourney = {} + const expectedAction = { + type: 'EDIT_NOTES_VEHICLEJOURNEY_MODAL', + vehicleJourney + } + expect(actions.openNotesEditModal(vehicleJourney)).toEqual(expectedAction) + }) +}) +describe('when clicking on a footnote button inside footnote modal', () => { + it('should create an action to toggle this footnote', () => { + const footnote = {}, isShown = true + const expectedAction = { + type: 'TOGGLE_FOOTNOTE_MODAL', + footnote, + isShown + } + expect(actions.toggleFootnoteModal(footnote, isShown)).toEqual(expectedAction) + }) +}) +describe('when clicking on validate button inside footnote modal', () => { + it('should create an action to update vj footnotes', () => { + const footnotes = [] + const expectedAction = { + type: 'EDIT_VEHICLEJOURNEY_NOTES', + footnotes + } + expect(actions.editVehicleJourneyNotes(footnotes)).toEqual(expectedAction) + }) +}) diff --git a/spec/javascripts/vehicle_journeys/reducers/modal_spec.js b/spec/javascripts/vehicle_journeys/reducers/modal_spec.js index 8e854be40..b41f0818f 100644 --- a/spec/javascripts/vehicle_journeys/reducers/modal_spec.js +++ b/spec/javascripts/vehicle_journeys/reducers/modal_spec.js @@ -49,4 +49,35 @@ describe('modal reducer', () => { }) ).toEqual(state) }) + + it('should handle EDIT_NOTES_VEHICLEJOURNEY_MODAL', () => { + let vehicleJourney = {} + let modalPropsResult = { + vehicleJourney: {} + } + expect( + modalReducer(state, { + type: 'EDIT_NOTES_VEHICLEJOURNEY_MODAL', + vehicleJourney + }) + ).toEqual(Object.assign({}, state, {type: 'notes_edit', modalProps: modalPropsResult})) + }) + + it('should handle TOGGLE_FOOTNOTE_MODAL', () => { + state.modalProps = {vehicleJourney : {footnotes: [{}, {}]}} + let footnote = {} + let newState = { + // for the sake of the test, no need to specify the type + type: '', + modalProps:{vehicleJourney: {footnotes: [{},{},{}]}}, + confirmModal: {} + } + expect( + modalReducer(state, { + type: 'TOGGLE_FOOTNOTE_MODAL', + footnote, + isShown: true + }) + ).toEqual(newState) + }) }) diff --git a/spec/javascripts/vehicle_journeys/reducers/vehicle_journeys_spec.js b/spec/javascripts/vehicle_journeys/reducers/vehicle_journeys_spec.js index 35d53a1fd..f0665a023 100644 --- a/spec/javascripts/vehicle_journeys/reducers/vehicle_journeys_spec.js +++ b/spec/javascripts/vehicle_journeys/reducers/vehicle_journeys_spec.js @@ -1,6 +1,11 @@ var vjReducer = require('es6_browserified/vehicle_journeys/reducers/vehicleJourneys') let state = [] +let stateModal = { + type: '', + modalProps: {}, + confirmModal: {} +} let fakeFootnotes = [{ id: 1, code: 1, @@ -214,4 +219,22 @@ describe('vehicleJourneys reducer', () => { }) ).toEqual([newVJ, state[1]]) }) + + + it('should handle EDIT_VEHICLEJOURNEY_NOTES', () => { + let fakeFootnote = { + id: 3, + code: 3, + label: "3" + } + fakeFootnotes.push(fakeFootnote) + let fakeFootnotesResult = fakeFootnotes.slice(0) + let newVJ = Object.assign({}, state[0], {footnotes: fakeFootnotesResult}) + expect( + vjReducer(state, { + type: 'EDIT_VEHICLEJOURNEY_NOTES', + footnotes: fakeFootnotesResult + }) + ).toEqual([newVJ, state[1]]) + }) }) |
