diff options
| author | Thomas Haddad | 2017-05-04 15:04:36 +0200 | 
|---|---|---|
| committer | Thomas Haddad | 2017-05-04 15:05:00 +0200 | 
| commit | ce845b8053d4fc665ca700c064cbd6f276bc4e1d (patch) | |
| tree | 6394e6fa4d8d51addcf9c38c67229e12cb96336a /spec/javascripts | |
| parent | 990cc5b907076793ce52c956a57e294b9730c379 (diff) | |
| download | chouette-core-ce845b8053d4fc665ca700c064cbd6f276bc4e1d.tar.bz2 | |
Add specs for redux timetable actions
Signed-off-by: Thomas Shawarma Haddad <thomas.haddad@af83.com>
Diffstat (limited to 'spec/javascripts')
| -rw-r--r-- | spec/javascripts/time_table/actions_spec.js | 158 | 
1 files changed, 157 insertions, 1 deletions
diff --git a/spec/javascripts/time_table/actions_spec.js b/spec/javascripts/time_table/actions_spec.js index eac2f86bb..73b2d2ac9 100644 --- a/spec/javascripts/time_table/actions_spec.js +++ b/spec/javascripts/time_table/actions_spec.js @@ -1,5 +1,16 @@  var actions = require('es6_browserified/time_tables/actions') - +const dispatch = function(){} +const dayTypes = [true, true, true, true, true, true, true] +const day = { +  date : "2017-05-01", +  day : "lundi", +  excluded_date : false, +  in_periods : true, +  include_date : false, +  mday : 1, +  wday : 1, +  wnumber : "18" +}  describe('actions', () => {    it('should create an action to update dayTypes', () => {      const expectedAction = { @@ -48,4 +59,149 @@ describe('actions', () => {      }      expect(actions.unselect2Tags(selectedItem)).toEqual(expectedAction)    }) + + +  it('should create an action to go to previous page', () => { +    let pagination = { +      currentPage: '2017-01-01', +      periode_range: [], +      stateChanged: false +    } +    const expectedAction = { +      type: 'GO_TO_PREVIOUS_PAGE', +      dispatch, +      pagination, +      nextPage: false +    } +    expect(actions.goToPreviousPage(dispatch, pagination)).toEqual(expectedAction) +  }) + +  it('should create an action to go to next page', () => { +    let pagination = { +      currentPage: '2017-01-01', +      periode_range: [], +      stateChanged: false +    } +    const expectedAction = { +      type: 'GO_TO_NEXT_PAGE', +      dispatch, +      pagination, +      nextPage: true +    } +    expect(actions.goToNextPage(dispatch, pagination)).toEqual(expectedAction) +  }) + +  it('should create an action to change page', () => { +    let page = '2017-05-04' +    const expectedAction = { +      type: 'CHANGE_PAGE', +      dispatch, +      page: page +    } +    expect(actions.changePage(dispatch, page)).toEqual(expectedAction) +  }) + +  it('should create an action to delete period', () => { +    let index = 1 +    const expectedAction = { +      type: 'DELETE_PERIOD', +      index, +      dayTypes +    } +    expect(actions.deletePeriod(index, dayTypes)).toEqual(expectedAction) +  }) + +  it('should create an action to open add period form', () => { +    const expectedAction = { +      type: 'OPEN_ADD_PERIOD_FORM', +    } +    expect(actions.openAddPeriodForm()).toEqual(expectedAction) +  }) + +  it('should create an action to open edit period form', () => { +    let period = { +      id : 1, +      period_end : "2017-03-05", +      period_start : "2017-02-23" +    } +    let index = 1 +    const expectedAction = { +      type: 'OPEN_EDIT_PERIOD_FORM', +      period, +      index +    } +    expect(actions.openEditPeriodForm(period, index)).toEqual(expectedAction) +  }) + +  it('should create an action to close period form', () => { +    const expectedAction = { +      type: 'CLOSE_PERIOD_FORM', +    } +    expect(actions.closePeriodForm()).toEqual(expectedAction) +  }) + +  it('should create an action to update period form', () => { +    let val = "11" +    let group = "start" +    let selectType = "day" +    const expectedAction = { +      type: 'UPDATE_PERIOD_FORM', +      val, +      group, +      selectType +    } +    expect(actions.updatePeriodForm(val, group, selectType)).toEqual(expectedAction) +  }) + +  it('should create an action to validate period form', () => { +    let modalProps = {} +    let timeTablePeriods = [] +    let metas = {} +    const expectedAction = { +      type: 'VALIDATE_PERIOD_FORM', +      modalProps, +      timeTablePeriods, +      metas +    } +    expect(actions.validatePeriodForm(modalProps, timeTablePeriods, metas)).toEqual(expectedAction) +  }) + +  it('should create an action to include date in period', () => { +    let index = 1 +    const expectedAction = { +      type: 'INCLUDE_DATE_IN_PERIOD', +      index, +      day, +      dayTypes +    } +    expect(actions.includeDateInPeriod(index, day, dayTypes)).toEqual(expectedAction) +  }) + +  it('should create an action to exclude date from period', () => { +    let index = 1 +    const expectedAction = { +      type: 'EXCLUDE_DATE_FROM_PERIOD', +      index, +      day, +      dayTypes +    } +    expect(actions.excludeDateFromPeriod(index, day, dayTypes)).toEqual(expectedAction) +  }) + +  it('should create an action to open confirm modal', () => { +    let callback = function(){} +    const expectedAction = { +      type: 'OPEN_CONFIRM_MODAL', +      callback +    } +    expect(actions.openConfirmModal(callback)).toEqual(expectedAction) +  }) + +  it('should create an action to close modal', () => { +    const expectedAction = { +      type: 'CLOSE_MODAL', +    } +    expect(actions.closeModal()).toEqual(expectedAction) +  }) +  })  | 
