diff options
| author | cedricnjanga | 2017-08-04 00:04:34 +0200 |
|---|---|---|
| committer | cedricnjanga | 2017-08-16 09:28:48 +0200 |
| commit | 76b1f8dfdaaeac516c51f91cc5df9f1e39ede0c0 (patch) | |
| tree | 11a63145d8a1f66f374d95e72521a545d6cd41b0 /spec/javascripts | |
| parent | 5f13f78bc5c116ca276e59fe39faa5d432bddece (diff) | |
| download | chouette-core-76b1f8dfdaaeac516c51f91cc5df9f1e39ede0c0.tar.bz2 | |
Adapt test to timetable changes
Diffstat (limited to 'spec/javascripts')
| -rw-r--r-- | spec/javascripts/time_table/actions_spec.js | 6 | ||||
| -rw-r--r-- | spec/javascripts/time_table/reducers/modal_spec.js | 74 | ||||
| -rw-r--r-- | spec/javascripts/time_table/reducers/timetable_spec.js | 9 |
3 files changed, 83 insertions, 6 deletions
diff --git a/spec/javascripts/time_table/actions_spec.js b/spec/javascripts/time_table/actions_spec.js index ebd1bb04c..01e5ba0f7 100644 --- a/spec/javascripts/time_table/actions_spec.js +++ b/spec/javascripts/time_table/actions_spec.js @@ -157,14 +157,16 @@ describe('actions', () => { it('should create an action to validate period form', () => { let modalProps = {} let timeTablePeriods = [] + let timeTableDates = [] let metas = {} const expectedAction = { type: 'VALIDATE_PERIOD_FORM', modalProps, timeTablePeriods, - metas + metas, + timeTableDates } - expect(actions.validatePeriodForm(modalProps, timeTablePeriods, metas)).toEqual(expectedAction) + expect(actions.validatePeriodForm(modalProps, timeTablePeriods, metas, timeTableDates)).toEqual(expectedAction) }) it('should create an action to include date in period', () => { diff --git a/spec/javascripts/time_table/reducers/modal_spec.js b/spec/javascripts/time_table/reducers/modal_spec.js index 4246027b8..8e9ebcd11 100644 --- a/spec/javascripts/time_table/reducers/modal_spec.js +++ b/spec/javascripts/time_table/reducers/modal_spec.js @@ -170,12 +170,14 @@ describe('modal reducer', () => { } let ttperiods = [] + let ttdates = [] expect( modalReducer(state, { type: 'VALIDATE_PERIOD_FORM', modalProps : modProps, - timeTablePeriods: ttperiods + timeTablePeriods: ttperiods, + timeTableDates: ttdates }) ).toEqual(Object.assign({}, state, {modalProps: newModalProps})) }) @@ -222,6 +224,8 @@ describe('modal reducer', () => { {id: 265, period_start: '2017-05-14', period_end: '2017-05-24'} ] + let ttdates2 = [] + let newModalProps2 = { active: true, begin: { @@ -242,8 +246,74 @@ describe('modal reducer', () => { modalReducer(state2, { type: 'VALIDATE_PERIOD_FORM', modalProps : modProps2, - timeTablePeriods: ttperiods2 + timeTablePeriods: ttperiods2, + timeTableDates: ttdates2 }) ).toEqual(Object.assign({}, state2, {modalProps: newModalProps2})) }) + + it('should handle VALIDATE_PERIOD_FORM and throw error if period overlaps date', () => { + let state3 = { + confirmModal: {}, + modalProps: { + active: false, + begin: { + day: '01', + month: '08', + year: '2017' + }, + end: { + day: '09', + month: '08', + year: '2017' + }, + index: false, + error: '' + }, + type: '' + } + let modProps3 = { + active: false, + begin: { + day: '01', + month: '08', + year: '2017' + }, + end: { + day: '09', + month: '08', + year: '2017' + }, + index: false, + error: '' + } + let ttperiods3 = [] + + let ttdates3 = [{date: "2017-08-04", include_date: true}] + + let newModalProps3 = { + active: true, + begin: { + day: '01', + month: '08', + year: '2017' + }, + end: { + day: '09', + month: '08', + year: '2017' + }, + index: false, + error: "Une période ne peut chevaucher une date dans un calendrier" + } + + expect( + modalReducer(state3, { + type: 'VALIDATE_PERIOD_FORM', + modalProps : modProps3, + timeTablePeriods: ttperiods3, + timeTableDates: ttdates3 + }) + ).toEqual(Object.assign({}, state3, {modalProps: newModalProps3})) + }) }) diff --git a/spec/javascripts/time_table/reducers/timetable_spec.js b/spec/javascripts/time_table/reducers/timetable_spec.js index 0b418a52e..d9cc2fc07 100644 --- a/spec/javascripts/time_table/reducers/timetable_spec.js +++ b/spec/javascripts/time_table/reducers/timetable_spec.js @@ -12,12 +12,15 @@ let current_month = [{"day":"lundi","date":"2017-05-01","wday":1,"wnumber":"18", let newCurrentMonth = [{"day":"lundi","date":"2017-05-01","wday":1,"wnumber":"18","mday":1,"include_date":false,"excluded_date":false,"in_periods":true},{"day":"mardi","date":"2017-05-02","wday":2,"wnumber":"18","mday":2,"include_date":false,"excluded_date":false,"in_periods":true},{"day":"mercredi","date":"2017-05-03","wday":3,"wnumber":"18","mday":3,"include_date":false,"excluded_date":false,"in_periods":true},{"day":"jeudi","date":"2017-05-04","wday":4,"wnumber":"18","mday":4,"include_date":false,"excluded_date":false,"in_periods":true},{"day":"vendredi","date":"2017-05-05","wday":5,"wnumber":"18","mday":5,"include_date":false,"excluded_date":false,"in_periods":false},{"day":"samedi","date":"2017-05-06","wday":6,"wnumber":"18","mday":6,"include_date":false,"excluded_date":false,"in_periods":false},{"day":"dimanche","date":"2017-05-07","wday":0,"wnumber":"18","mday":7,"include_date":false,"excluded_date":false,"in_periods":false},{"day":"lundi","date":"2017-05-08","wday":1,"wnumber":"19","mday":8,"include_date":false,"excluded_date":false,"in_periods":false},{"day":"mardi","date":"2017-05-09","wday":2,"wnumber":"19","mday":9,"include_date":false,"excluded_date":false,"in_periods":false},{"day":"mercredi","date":"2017-05-10","wday":3,"wnumber":"19","mday":10,"include_date":false,"excluded_date":false,"in_periods":false},{"day":"jeudi","date":"2017-05-11","wday":4,"wnumber":"19","mday":11,"include_date":false,"excluded_date":false,"in_periods":false},{"day":"vendredi","date":"2017-05-12","wday":5,"wnumber":"19","mday":12,"include_date":false,"excluded_date":false,"in_periods":false},{"day":"samedi","date":"2017-05-13","wday":6,"wnumber":"19","mday":13,"include_date":false,"excluded_date":false,"in_periods":false},{"day":"dimanche","date":"2017-05-14","wday":0,"wnumber":"19","mday":14,"include_date":false,"excluded_date":false,"in_periods":true},{"day":"lundi","date":"2017-05-15","wday":1,"wnumber":"20","mday":15,"include_date":false,"excluded_date":false,"in_periods":true},{"day":"mardi","date":"2017-05-16","wday":2,"wnumber":"20","mday":16,"include_date":false,"excluded_date":false,"in_periods":true},{"day":"mercredi","date":"2017-05-17","wday":3,"wnumber":"20","mday":17,"include_date":false,"excluded_date":false,"in_periods":true},{"day":"jeudi","date":"2017-05-18","wday":4,"wnumber":"20","mday":18,"include_date":false,"excluded_date":false,"in_periods":true},{"day":"vendredi","date":"2017-05-19","wday":5,"wnumber":"20","mday":19,"include_date":false,"excluded_date":false,"in_periods":true},{"day":"samedi","date":"2017-05-20","wday":6,"wnumber":"20","mday":20,"include_date":false,"excluded_date":false,"in_periods":true},{"day":"dimanche","date":"2017-05-21","wday":0,"wnumber":"20","mday":21,"include_date":false,"excluded_date":false,"in_periods":true},{"day":"lundi","date":"2017-05-22","wday":1,"wnumber":"21","mday":22,"include_date":false,"excluded_date":false,"in_periods":true},{"day":"mardi","date":"2017-05-23","wday":2,"wnumber":"21","mday":23,"include_date":false,"excluded_date":false,"in_periods":true},{"day":"mercredi","date":"2017-05-24","wday":3,"wnumber":"21","mday":24,"include_date":false,"excluded_date":false,"in_periods":true},{"day":"jeudi","date":"2017-05-25","wday":4,"wnumber":"21","mday":25,"include_date":false,"excluded_date":false,"in_periods":false},{"day":"vendredi","date":"2017-05-26","wday":5,"wnumber":"21","mday":26,"include_date":false,"excluded_date":false,"in_periods":false},{"day":"samedi","date":"2017-05-27","wday":6,"wnumber":"21","mday":27,"include_date":false,"excluded_date":false,"in_periods":false},{"day":"dimanche","date":"2017-05-28","wday":0,"wnumber":"21","mday":28,"include_date":false,"excluded_date":false,"in_periods":false},{"day":"lundi","date":"2017-05-29","wday":1,"wnumber":"22","mday":29,"include_date":false,"excluded_date":false,"in_periods":false},{"day":"mardi","date":"2017-05-30","wday":2,"wnumber":"22","mday":30,"include_date":false,"excluded_date":false,"in_periods":false},{"day":"mercredi","date":"2017-05-31","wday":3,"wnumber":"22","mday":31,"include_date":false,"excluded_date":false,"in_periods":false}] +let time_table_dates = current_month.filter( ({include_date}) => !!include_date) + let json = { current_month: current_month, current_periode_range: current_periode_range, periode_range: periode_range, time_table_periods: time_table_periods, - day_types: strDayTypes + day_types: strDayTypes, + time_table_dates: time_table_dates } describe('timetable reducer with empty state', () => { @@ -59,6 +62,7 @@ describe('timetable reducer with filled state', () => { current_periode_range: current_periode_range, periode_range: periode_range, time_table_periods: time_table_periods, + time_table_dates: time_table_dates } }) @@ -177,7 +181,8 @@ describe('timetable reducer with filled state', () => { timeTablePeriods: state.time_table_periods, metas: { day_types: arrDayTypes - } + }, + timeTableDates: state.time_table_dates }) ).toEqual(state) }) |
