@@ -316,22 +316,22 @@ describe('DetailsFieldsComponent', () => {
316316 } ) ;
317317
318318 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 ( ) } ` ) ;
322322
323323 component . entryToEdit = { ...entryToEdit , start_date : expectedStartDate } ;
324324 fixture . componentInstance . ngOnChanges ( ) ;
325325
326326 component . entryForm . patchValue ( { description : 'test' } ) ;
327327
328- expect ( component . startDateToSubmit ( ) ) . toEqual ( expectedStartDate ) ;
328+ expect ( component . dateToSubmit ( 'start_date' , 'start_hour' ) ) . toEqual ( expectedStartDate ) ;
329329 } ) ;
330330
331331 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 ( ) } ` ) ;
335335
336336 component . entryToEdit = { ...entryToEdit , start_date : startDate } ;
337337 fixture . componentInstance . ngOnChanges ( ) ;
@@ -341,26 +341,26 @@ describe('DetailsFieldsComponent', () => {
341341 component . entryForm . patchValue ( { start_hour : updatedStartHour } ) ;
342342
343343 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 ) ;
345345 } ) ;
346346
347347 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 ( ) } ` ) ;
351351
352352 component . entryToEdit = { ...entryToEdit , end_date : expectedEndDate } ;
353353 fixture . componentInstance . ngOnChanges ( ) ;
354354
355355 component . entryForm . patchValue ( { description : 'test' } ) ;
356356
357- expect ( component . endDateToSubmit ( ) ) . toEqual ( expectedEndDate ) ;
357+ expect ( component . dateToSubmit ( 'end_date' , 'end_hour' ) ) . toEqual ( expectedEndDate ) ;
358358 } ) ;
359359
360360 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 ( ) } ` ) ;
364364
365365 component . entryToEdit = { ...entryToEdit , end_date : endDate } ;
366366 fixture . componentInstance . ngOnChanges ( ) ;
@@ -370,7 +370,7 @@ describe('DetailsFieldsComponent', () => {
370370 component . entryForm . patchValue ( { end_hour : updatedEndHour } ) ;
371371
372372 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 ) ;
374374 } ) ;
375375
376376 it ( 'displays error message when the date selected is in the future' , ( ) => {
0 commit comments