diff options
Diffstat (limited to 'spec/javascript')
| -rw-r--r-- | spec/javascript/journey_patterns/actions_spec.js | 16 | ||||
| -rw-r--r-- | spec/javascript/journey_patterns/reducers/journey_patterns_spec.js | 38 | 
2 files changed, 51 insertions, 3 deletions
| diff --git a/spec/javascript/journey_patterns/actions_spec.js b/spec/javascript/journey_patterns/actions_spec.js index 2542fa2f4..60d6d88bb 100644 --- a/spec/javascript/journey_patterns/actions_spec.js +++ b/spec/javascript/journey_patterns/actions_spec.js @@ -112,6 +112,22 @@ describe('when clicking on a journey pattern delete button', () => {      expect(actions.deleteJourneyPattern(index)).toEqual(expectedAction)    })  }) +describe('when changing on a journey pattern costs', () => { +  it('should create an action to update journey pattern', () => { +    const index = 1 +    const costs = { +      "1-2": { +        distance: 1 +      } +    } +    const expectedAction = { +      type: 'UPDATE_JOURNEYPATTERN_COSTS', +      index, +      costs +    } +    expect(actions.updateJourneyPatternCosts(index, costs)).toEqual(expectedAction) +  }) +})  describe('when clicking on validate button inside edit modal', () => {    it('should create an action to save journey pattern modifications', () => {      const index = 1 diff --git a/spec/javascript/journey_patterns/reducers/journey_patterns_spec.js b/spec/javascript/journey_patterns/reducers/journey_patterns_spec.js index 24780ab5a..bfa87d24a 100644 --- a/spec/javascript/journey_patterns/reducers/journey_patterns_spec.js +++ b/spec/javascript/journey_patterns/reducers/journey_patterns_spec.js @@ -47,7 +47,10 @@ describe('journeyPatterns reducer', () => {          object_id : 'o1',          published_name: 'M1',          registration_number: '', -        stop_points: fakeStopPoints +        stop_points: fakeStopPoints, +        costs: { + +        }        },        {          deletable: false, @@ -55,7 +58,13 @@ describe('journeyPatterns reducer', () => {          object_id : 'o2',          published_name: 'M2',          registration_number: '', -        stop_points: fakeStopPoints +        stop_points: fakeStopPoints, +        costs: { +          "1-2": { +            distance: 0, +            time: 10, +          } +        }        }      ]    }) @@ -83,7 +92,8 @@ describe('journeyPatterns reducer', () => {        published_name: 'M3',        registration_number: '',        deletable: false, -      stop_points: stopPoints +      stop_points: stopPoints, +      costs: {}      }, ...state])    }) @@ -100,6 +110,28 @@ describe('journeyPatterns reducer', () => {      ).toEqual([newState, state[1]])    }) +  it('should handle UPDATE_JOURNEYPATTERN_COSTS', () => { +    const costs = { +      "1-2": { +        distance: 1 +      } +    } +    const new_costs = { +      "1-2": { +        distance: 1, +        time: 10, +      } +    } +    const new_state = Object.assign({}, state[1], {costs: new_costs}) +    expect( +      jpReducer(state, { +        type: 'UPDATE_JOURNEYPATTERN_COSTS', +        index: 1, +        costs +      }) +    ).toEqual([state[0], new_state]) +  }) +    it('should handle DELETE_JOURNEYPATTERN', () => {      expect(        jpReducer(state, { | 
