@@ -26,7 +26,7 @@ describe('osrdconfReducer', () => {
26
26
expect ( state . osrdconf . originTime ) . toEqual ( '08:00:00' ) ;
27
27
expect ( state . osrdconf . originUpperBoundTime ) . toEqual ( '15:30:00' ) ;
28
28
} ) ;
29
- it ( 'should update originUpperBoundTime if linked' , ( ) => {
29
+ it ( 'should update originUpperBoundTime if linked, and keep the difference between the two ' , ( ) => {
30
30
const store = createStore ( {
31
31
originLinkedBounds : true ,
32
32
originTime : '11:00:00' ,
@@ -38,21 +38,47 @@ describe('osrdconfReducer', () => {
38
38
39
39
const state = store . getState ( ) ;
40
40
expect ( state . osrdconf . originTime ) . toEqual ( '08:00:00' ) ;
41
- expect ( state . osrdconf . originUpperBoundTime ) . toEqual ( '10:00 :00' ) ;
41
+ expect ( state . osrdconf . originUpperBoundTime ) . toEqual ( '12:30 :00' ) ;
42
42
} ) ;
43
- it ( 'should not make upper bound go beyond midnight ' , ( ) => {
43
+ it ( 'should use the default difference when originTime is not defined ' , ( ) => {
44
44
const store = createStore ( {
45
45
originLinkedBounds : true ,
46
- originTime : '11:00:00' ,
47
46
originUpperBoundTime : '15:30:00' ,
48
47
} ) ;
49
48
50
- const action = updateOriginTime ( '23:30:00' ) ;
49
+ const action = updateOriginTime ( '08:00:00' ) ;
50
+ store . dispatch ( action ) ;
51
+
52
+ const state = store . getState ( ) ;
53
+ expect ( state . osrdconf . originTime ) . toEqual ( '08:00:00' ) ;
54
+ expect ( state . osrdconf . originUpperBoundTime ) . toEqual ( '10:00:00' ) ;
55
+ } ) ;
56
+ it ( 'should use the default difference when originUpperBoundTime is not defined' , ( ) => {
57
+ const store = createStore ( {
58
+ originLinkedBounds : true ,
59
+ originTime : '10:00:00' ,
60
+ } ) ;
61
+
62
+ const action = updateOriginTime ( '08:00:00' ) ;
63
+ store . dispatch ( action ) ;
64
+
65
+ const state = store . getState ( ) ;
66
+ expect ( state . osrdconf . originTime ) . toEqual ( '08:00:00' ) ;
67
+ expect ( state . osrdconf . originUpperBoundTime ) . toEqual ( '10:00:00' ) ;
68
+ } ) ;
69
+ test ( 'lower bound should not go above upper bound when unlinked' , ( ) => {
70
+ const store = createStore ( {
71
+ originLinkedBounds : false ,
72
+ originTime : '10:00:00' ,
73
+ originUpperBoundTime : '12:00:00' ,
74
+ } ) ;
75
+
76
+ const action = updateOriginTime ( '13:00:00' ) ;
51
77
store . dispatch ( action ) ;
52
78
53
79
const state = store . getState ( ) ;
54
- expect ( state . osrdconf . originTime ) . toEqual ( '23:30 :00' ) ;
55
- expect ( state . osrdconf . originUpperBoundTime ) . toEqual ( '23:59:59 ' ) ;
80
+ expect ( state . osrdconf . originTime ) . toEqual ( '12:00 :00' ) ;
81
+ expect ( state . osrdconf . originUpperBoundTime ) . toEqual ( '12:00:00 ' ) ;
56
82
} ) ;
57
83
} ) ;
58
84
describe ( 'updateOriginUpperBoundTime' , ( ) => {
@@ -70,11 +96,24 @@ describe('osrdconfReducer', () => {
70
96
expect ( state . osrdconf . originTime ) . toEqual ( '11:00:00' ) ;
71
97
expect ( state . osrdconf . originUpperBoundTime ) . toEqual ( '20:00:00' ) ;
72
98
} ) ;
73
- it ( 'should update originTime if linked' , ( ) => {
99
+ it ( 'should update originTime if linked, keeping the current difference between the two ' , ( ) => {
74
100
const store = createStore ( {
75
101
originLinkedBounds : true ,
76
102
originTime : '11:00:00' ,
77
- originUpperBoundTime : '15:30:00' ,
103
+ originUpperBoundTime : '14:00:00' ,
104
+ } ) ;
105
+
106
+ const action = updateOriginUpperBoundTime ( '20:00:00' ) ;
107
+ store . dispatch ( action ) ;
108
+
109
+ const state = store . getState ( ) ;
110
+ expect ( state . osrdconf . originTime ) . toEqual ( '17:00:00' ) ;
111
+ expect ( state . osrdconf . originUpperBoundTime ) . toEqual ( '20:00:00' ) ;
112
+ } ) ;
113
+ it ( 'should use default difference if originTime not defined' , ( ) => {
114
+ const store = createStore ( {
115
+ originLinkedBounds : true ,
116
+ originUpperBoundTime : '14:00:00' ,
78
117
} ) ;
79
118
80
119
const action = updateOriginUpperBoundTime ( '20:00:00' ) ;
@@ -84,19 +123,32 @@ describe('osrdconfReducer', () => {
84
123
expect ( state . osrdconf . originTime ) . toEqual ( '18:00:00' ) ;
85
124
expect ( state . osrdconf . originUpperBoundTime ) . toEqual ( '20:00:00' ) ;
86
125
} ) ;
87
- it ( 'should not make originTime go below 0 ' , ( ) => {
126
+ it ( 'should use default difference if originUpperBoundTime not defined ' , ( ) => {
88
127
const store = createStore ( {
89
128
originLinkedBounds : true ,
90
- originTime : '11:00:00' ,
91
- originUpperBoundTime : '15:30:00' ,
129
+ originTime : '14:00:00' ,
130
+ } ) ;
131
+
132
+ const action = updateOriginUpperBoundTime ( '20:00:00' ) ;
133
+ store . dispatch ( action ) ;
134
+
135
+ const state = store . getState ( ) ;
136
+ expect ( state . osrdconf . originTime ) . toEqual ( '18:00:00' ) ;
137
+ expect ( state . osrdconf . originUpperBoundTime ) . toEqual ( '20:00:00' ) ;
138
+ } ) ;
139
+ test ( 'upper bound should not go below lower bonud when unlinked' , ( ) => {
140
+ const store = createStore ( {
141
+ originLinkedBounds : false ,
142
+ originTime : '14:00:00' ,
143
+ originUpperBoundTime : '18:00:00' ,
92
144
} ) ;
93
145
94
- const action = updateOriginUpperBoundTime ( '00:30 :00' ) ;
146
+ const action = updateOriginUpperBoundTime ( '12:00 :00' ) ;
95
147
store . dispatch ( action ) ;
96
148
97
149
const state = store . getState ( ) ;
98
- expect ( state . osrdconf . originTime ) . toEqual ( '00 :00:00' ) ;
99
- expect ( state . osrdconf . originUpperBoundTime ) . toEqual ( '00:30 :00' ) ;
150
+ expect ( state . osrdconf . originTime ) . toEqual ( '14 :00:00' ) ;
151
+ expect ( state . osrdconf . originUpperBoundTime ) . toEqual ( '14:00 :00' ) ;
100
152
} ) ;
101
153
} ) ;
102
154
describe ( 'toggleOriginLinkedBounds' , ( ) => {
0 commit comments