diff options
| author | jpl | 2017-05-05 12:39:35 +0200 | 
|---|---|---|
| committer | jpl | 2017-05-05 12:39:35 +0200 | 
| commit | c1b2c713d1fd355e1e5e853bf1d0c5fa95c8bb72 (patch) | |
| tree | f50d001b183fb6ec51e6fda242040b0a1b569cd7 /spec/javascripts/time_table | |
| parent | 1968d5bee72e745737e7137348d7f53599b9375f (diff) | |
| download | chouette-core-c1b2c713d1fd355e1e5e853bf1d0c5fa95c8bb72.tar.bz2 | |
adding reducer tests for timetables reactux (2)
Diffstat (limited to 'spec/javascripts/time_table')
| -rw-r--r-- | spec/javascripts/time_table/reducers/modal_spec.js | 72 | 
1 files changed, 68 insertions, 4 deletions
diff --git a/spec/javascripts/time_table/reducers/modal_spec.js b/spec/javascripts/time_table/reducers/modal_spec.js index ceed0a43e..4246027b8 100644 --- a/spec/javascripts/time_table/reducers/modal_spec.js +++ b/spec/javascripts/time_table/reducers/modal_spec.js @@ -137,10 +137,7 @@ describe('modal reducer', () => {      ).toEqual(Object.assign({}, state, {modalProps: newModalProps}))    }) -  it('should handle VALIDATE_PERIOD_FORM', () => { -    // if period_end <= period_start, throw error -    // if newperiod is on another one, throw error - +  it('should handle VALIDATE_PERIOD_FORM and throw error if period starts after the end', () => {      let modProps = {        active: false,        begin: { @@ -182,4 +179,71 @@ describe('modal reducer', () => {        })      ).toEqual(Object.assign({}, state, {modalProps: newModalProps}))    }) + +  it('should handle VALIDATE_PERIOD_FORM and throw error if periods overlap', () => { +    let state2 = { +      confirmModal: {}, +      modalProps: { +        active: false, +        begin: { +          day: '03', +          month: '05', +          year: '2017' +        }, +        end: { +          day: '09', +          month: '05', +          year: '2017' +        }, +        index: false, +        error: '' +      }, +      type: '' +    } +    let modProps2 = { +      active: false, +      begin: { +        day: '03', +        month: '05', +        year: '2017' +      }, +      end: { +        day: '09', +        month: '05', +        year: '2017' +      }, +      index: false, +      error: '' +    } +    let ttperiods2 = [ +      {id: 261, period_start: '2017-02-23', period_end: '2017-03-05'}, +      {id: 262, period_start: '2017-03-15', period_end: '2017-03-25'}, +      {id: 264, period_start: '2017-04-24', period_end: '2017-05-04'}, +      {id: 265, period_start: '2017-05-14', period_end: '2017-05-24'} +    ] + +    let newModalProps2 = { +      active: true, +      begin: { +        day: '03', +        month: '05', +        year: '2017' +      }, +      end: { +        day: '09', +        month: '05', +        year: '2017' +      }, +      index: false, +      error: "Les périodes ne peuvent pas se chevaucher" +    } + +    expect( +      modalReducer(state2, { +        type: 'VALIDATE_PERIOD_FORM', +        modalProps : modProps2, +        timeTablePeriods: ttperiods2 +      }) +    ).toEqual(Object.assign({}, state2, {modalProps: newModalProps2})) +  })  })  | 
