@@ -316,22 +316,22 @@ describe('DetailsFieldsComponent', () => {
316
316
} ) ;
317
317
318
318
it ( 'should not modify the start_date when start_hour has not been modified' , ( ) => {
319
- const dateTest = moment ( ) . format ( 'YYYY-MM-DD' ) ;
320
- const startHourTest = moment ( ) . subtract ( 3 , 'hours' ) . format ( 'HH:mm:ss' ) ;
321
- const expectedStartDate = new Date ( `${ dateTest } T${ startHourTest . trim ( ) } ` ) ;
319
+ const currentDate = moment ( ) . format ( 'YYYY-MM-DD' ) ;
320
+ const startHour = moment ( ) . subtract ( 3 , 'hours' ) . format ( 'HH:mm:ss' ) ;
321
+ const expectedStartDate = new Date ( `${ currentDate } T${ startHour . trim ( ) } ` ) ;
322
322
323
323
component . entryToEdit = { ...entryToEdit , start_date : expectedStartDate } ;
324
324
fixture . componentInstance . ngOnChanges ( ) ;
325
325
326
326
component . entryForm . patchValue ( { description : 'test' } ) ;
327
327
328
- expect ( component . startDateToSubmit ( ) ) . toEqual ( expectedStartDate ) ;
328
+ expect ( component . dateToSubmit ( 'start_date' , 'start_hour' ) ) . toEqual ( expectedStartDate ) ;
329
329
} ) ;
330
330
331
331
it ( 'should modify the start_date when start_hour has been modified' , ( ) => {
332
- const dateTest = moment ( ) . format ( 'YYYY-MM-DD' ) ;
333
- const startHourTest = moment ( ) . format ( 'HH:mm:ss' ) ;
334
- const startDate = new Date ( `${ dateTest } T${ startHourTest . trim ( ) } ` ) ;
332
+ const currentDate = moment ( ) . format ( 'YYYY-MM-DD' ) ;
333
+ const startHour = moment ( ) . format ( 'HH:mm:ss' ) ;
334
+ const startDate = new Date ( `${ currentDate } T${ startHour . trim ( ) } ` ) ;
335
335
336
336
component . entryToEdit = { ...entryToEdit , start_date : startDate } ;
337
337
fixture . componentInstance . ngOnChanges ( ) ;
@@ -341,26 +341,26 @@ describe('DetailsFieldsComponent', () => {
341
341
component . entryForm . patchValue ( { start_hour : updatedStartHour } ) ;
342
342
343
343
const expectedStartDate = moment ( updatedStartDate ) . seconds ( 0 ) . millisecond ( 0 ) . toISOString ( ) ;
344
- expect ( component . startDateToSubmit ( ) ) . toEqual ( expectedStartDate ) ;
344
+ expect ( component . dateToSubmit ( 'start_date' , 'start_hour' ) ) . toEqual ( expectedStartDate ) ;
345
345
} ) ;
346
346
347
347
it ( 'should not modify the end_date when end_hour has not been modified' , ( ) => {
348
- const dateTest = moment ( ) . format ( 'YYYY-MM-DD' ) ;
349
- const endtHourTest = moment ( ) . subtract ( 3 , 'hours' ) . format ( 'HH:mm:ss' ) ;
350
- const expectedEndDate = new Date ( `${ dateTest } T${ endtHourTest . trim ( ) } ` ) ;
348
+ const currentDate = moment ( ) . format ( 'YYYY-MM-DD' ) ;
349
+ const endHour = moment ( ) . subtract ( 3 , 'hours' ) . format ( 'HH:mm:ss' ) ;
350
+ const expectedEndDate = new Date ( `${ currentDate } T${ endHour . trim ( ) } ` ) ;
351
351
352
352
component . entryToEdit = { ...entryToEdit , end_date : expectedEndDate } ;
353
353
fixture . componentInstance . ngOnChanges ( ) ;
354
354
355
355
component . entryForm . patchValue ( { description : 'test' } ) ;
356
356
357
- expect ( component . endDateToSubmit ( ) ) . toEqual ( expectedEndDate ) ;
357
+ expect ( component . dateToSubmit ( 'end_date' , 'end_hour' ) ) . toEqual ( expectedEndDate ) ;
358
358
} ) ;
359
359
360
360
it ( 'should modify the end_date when end_hour has been modified' , ( ) => {
361
- const dateTest = moment ( ) . format ( 'YYYY-MM-DD' ) ;
362
- const endHourTest = moment ( ) . format ( 'HH:mm:ss' ) ;
363
- const endDate = new Date ( `${ dateTest } T${ endHourTest . trim ( ) } ` ) ;
361
+ const currentDate = moment ( ) . format ( 'YYYY-MM-DD' ) ;
362
+ const endHour = moment ( ) . format ( 'HH:mm:ss' ) ;
363
+ const endDate = new Date ( `${ currentDate } T${ endHour . trim ( ) } ` ) ;
364
364
365
365
component . entryToEdit = { ...entryToEdit , end_date : endDate } ;
366
366
fixture . componentInstance . ngOnChanges ( ) ;
@@ -370,7 +370,7 @@ describe('DetailsFieldsComponent', () => {
370
370
component . entryForm . patchValue ( { end_hour : updatedEndHour } ) ;
371
371
372
372
const expectedEndDate = moment ( updatedEndDate ) . seconds ( 0 ) . millisecond ( 0 ) . toISOString ( ) ;
373
- expect ( component . endDateToSubmit ( ) ) . toEqual ( expectedEndDate ) ;
373
+ expect ( component . dateToSubmit ( 'end_date' , 'end_hour' ) ) . toEqual ( expectedEndDate ) ;
374
374
} ) ;
375
375
376
376
it ( 'displays error message when the date selected is in the future' , ( ) => {
0 commit comments