@@ -157,18 +157,22 @@ describe('EntryFieldsComponent', () => {
157
157
} ) ;
158
158
159
159
it ( 'displays error message when the date selected is in the future' , ( ) => {
160
+ const startMoment = moment ( ) ;
161
+ if ( startMoment . format ( 'HH' ) === '23' ) {
162
+ return ; // form logic does not handle day overlap
163
+ }
160
164
const mockEntry = {
161
165
...entry ,
162
- start_date : moment ( ) . format ( DATE_FORMAT_YEAR ) ,
163
- start_hour : moment ( ) . format ( 'HH:mm' )
166
+ start_date : startMoment . format ( DATE_FORMAT_YEAR ) ,
167
+ start_hour : startMoment . format ( 'HH:mm' )
164
168
} ;
165
169
166
170
component . newData = mockEntry ;
167
171
component . activeEntry = mockEntry ;
168
172
component . setDataToUpdate ( mockEntry ) ;
169
173
spyOn ( toastrServiceStub , 'error' ) ;
170
174
171
- const hourInTheFuture = moment ( ) . add ( 1 , 'hours' ) . format ( 'HH:mm' ) ;
175
+ const hourInTheFuture = startMoment . add ( 1 , 'hours' ) . format ( 'HH:mm' ) ;
172
176
component . entryForm . patchValue ( { start_hour : hourInTheFuture } ) ;
173
177
component . onUpdateStartHour ( ) ;
174
178
@@ -233,16 +237,20 @@ describe('EntryFieldsComponent', () => {
233
237
} ) ;
234
238
235
239
it ( 'If start hour is in the future, reset to initial start_date in form' , ( ) => {
240
+ const startMoment = moment ( ) ;
241
+ if ( startMoment . format ( 'HH' ) === '23' ) {
242
+ return ; // form logic does not handle day overlap
243
+ }
236
244
const mockEntry = {
237
245
...entry ,
238
- start_date : moment ( ) . format ( DATE_FORMAT_YEAR ) ,
239
- start_hour : moment ( ) . format ( 'HH:mm' )
246
+ start_date : startMoment . format ( DATE_FORMAT_YEAR ) ,
247
+ start_hour : startMoment . format ( 'HH:mm' )
240
248
} ;
241
249
component . newData = mockEntry ;
242
250
component . activeEntry = mockEntry ;
243
251
component . setDataToUpdate ( mockEntry ) ;
244
252
245
- const hourInTheFuture = moment ( ) . add ( 1 , 'hours' ) . format ( 'HH:mm' ) ;
253
+ const hourInTheFuture = startMoment . add ( 1 , 'hours' ) . format ( 'HH:mm' ) ;
246
254
component . entryForm . patchValue ( { start_hour : hourInTheFuture } ) ;
247
255
248
256
spyOn ( component . entryForm , 'patchValue' ) ;
0 commit comments