diff options
| author | Thomas Haddad | 2017-02-16 17:14:45 +0100 | 
|---|---|---|
| committer | Thomas Haddad | 2017-02-16 17:15:49 +0100 | 
| commit | bb693070b8f06bc9cb4845d27d58dfed9ce3411e (patch) | |
| tree | 0c0e2f155e98daa609ca04ab09fd4fd63bae7e21 /spec/javascripts | |
| parent | 051b25a06ae9cb5fd19791688eac6ba40ab56396 (diff) | |
| download | chouette-core-bb693070b8f06bc9cb4845d27d58dfed9ce3411e.tar.bz2 | |
Refs #2522: Add vehicleJourney via modal, and put it first (not select2 yet for mission_id)
Signed-off-by: Thomas Shawarma Haddad <thomas.haddad@af83.com>
Diffstat (limited to 'spec/javascripts')
3 files changed, 81 insertions, 0 deletions
diff --git a/spec/javascripts/vehicle_journeys/actions_spec.js b/spec/javascripts/vehicle_journeys/actions_spec.js index 5eb3abe45..9f3f5e168 100644 --- a/spec/javascripts/vehicle_journeys/actions_spec.js +++ b/spec/javascripts/vehicle_journeys/actions_spec.js @@ -29,6 +29,58 @@ describe('when receiveJourneyPatterns is triggered', () => {      expect(actions.receiveVehicleJourneys()).toEqual(expectedAction)    })  }) +describe('when clicking on add button', () => { +  it('should create an action to open a create modal', () => { +    const expectedAction = { +      type: 'CREATE_VEHICLEJOURNEY_MODAL', +    } +    expect(actions.openCreateModal()).toEqual(expectedAction) +  }) +}) +describe('when clicking on validate button inside create modal', () => { +  it('should create an action to create a new journey pattern', () => { +    const data = {} +    const expectedAction = { +      type: 'ADD_VEHICLEJOURNEY', +      data +    } +    expect(actions.addVehicleJourney(data)).toEqual(expectedAction) +  }) +}) +describe('when previous navigation button is clicked', () => { +  it('should create an action to go to previous page', () => { +    const nextPage = false +    const pagination = { +      totalCount: 25, +      perPage: 12, +      page:1 +    } +    const expectedAction = { +      type: 'GO_TO_PREVIOUS_PAGE', +      dispatch, +      pagination, +      nextPage +    } +    expect(actions.goToPreviousPage(dispatch, pagination)).toEqual(expectedAction) +  }) +}) +describe('when next navigation button is clicked', () => { +  it('should create an action to go to next page', () => { +    const nextPage = true +    const pagination = { +      totalCount: 25, +      perPage: 12, +      page:1 +    } +    const expectedAction = { +      type: 'GO_TO_NEXT_PAGE', +      dispatch, +      pagination, +      nextPage +    } +    expect(actions.goToNextPage(dispatch, pagination)).toEqual(expectedAction) +  }) +})  describe('when toggling arrivals', () => {    it('should create an action to toggleArrivals', () => {      const expectedAction = { diff --git a/spec/javascripts/vehicle_journeys/reducers/modal_spec.js b/spec/javascripts/vehicle_journeys/reducers/modal_spec.js index 8da8e6c65..8e854be40 100644 --- a/spec/javascripts/vehicle_journeys/reducers/modal_spec.js +++ b/spec/javascripts/vehicle_journeys/reducers/modal_spec.js @@ -34,6 +34,14 @@ describe('modal reducer', () => {      ).toEqual(newState)    }) +  it('should handle CREATE_VEHICLEJOURNEY_MODAL', () => { +    expect( +      modalReducer(state, { +        type: 'CREATE_VEHICLEJOURNEY_MODAL' +      }) +    ).toEqual(Object.assign({}, state, { type: 'create' })) +  }) +    it('should handle CLOSE_MODAL', () => {      expect(        modalReducer(state, { diff --git a/spec/javascripts/vehicle_journeys/reducers/vehicle_journeys_spec.js b/spec/javascripts/vehicle_journeys/reducers/vehicle_journeys_spec.js index 5540caf02..bb40add3a 100644 --- a/spec/javascripts/vehicle_journeys/reducers/vehicle_journeys_spec.js +++ b/spec/javascripts/vehicle_journeys/reducers/vehicle_journeys_spec.js @@ -55,6 +55,27 @@ describe('vehicleJourneys reducer', () => {    }) +  it('should handle ADD_VEHICLEJOURNEY', () => { +    let fakeData = { +      journey_pattern_id: {value : '1'}, +      comment: {value: 'test'} +    } +    expect( +      vjReducer(state, { +        type: 'ADD_VEHICLEJOURNEY', +        data: fakeData +      }) +    ).toEqual([{ +      journey_pattern_id: 1, +      comment: 'test', +      objectid: '', +      footnotes: [], +      time_tables: [], +      vehicle_journey_at_stops: [], +      deletable: false +    }, ...state]) +  }) +    it('should handle RECEIVE_VEHICLE_JOURNEYS', () => {      expect(        vjReducer(state, {  | 
