aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert2017-05-05 15:27:17 +0200
committerRobert2017-05-05 15:27:17 +0200
commita118a072a1084e9dce5e5e76898eeb4d12a29870 (patch)
tree844c15b4a2b021215bc4a34b5e3fa47cafe84cde
parent290b42e713e982c5bc900d25017ca7eb3ce7f585 (diff)
parentc1b2c713d1fd355e1e5e853bf1d0c5fa95c8bb72 (diff)
downloadchouette-core-a118a072a1084e9dce5e5e76898eeb4d12a29870.tar.bz2
Merge branch 'master' of github.com:af83/stif-boiv
-rw-r--r--spec/javascripts/time_table/reducers/modal_spec.js72
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}))
+ })
})