diff --git a/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts b/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts index 95c7af36f..37b3fb074 100644 --- a/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts +++ b/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts @@ -157,10 +157,14 @@ describe('EntryFieldsComponent', () => { }); it('displays error message when the date selected is in the future', () => { + const startMoment = moment(); + if (startMoment.format('HH') === '23') { + return; // form logic does not handle day overlap + } const mockEntry = { ...entry, - start_date: moment().format(DATE_FORMAT_YEAR), - start_hour: moment().format('HH:mm') + start_date: startMoment.format(DATE_FORMAT_YEAR), + start_hour: startMoment.format('HH:mm') }; component.newData = mockEntry; @@ -168,7 +172,7 @@ describe('EntryFieldsComponent', () => { component.setDataToUpdate(mockEntry); spyOn(toastrServiceStub, 'error'); - const hourInTheFuture = moment().add(1, 'hours').format('HH:mm'); + const hourInTheFuture = startMoment.add(1, 'hours').format('HH:mm'); component.entryForm.patchValue({ start_hour: hourInTheFuture }); component.onUpdateStartHour(); @@ -233,16 +237,20 @@ describe('EntryFieldsComponent', () => { }); it('If start hour is in the future, reset to initial start_date in form', () => { + const startMoment = moment(); + if (startMoment.format('HH') === '23') { + return; // form logic does not handle day overlap + } const mockEntry = { ...entry, - start_date: moment().format(DATE_FORMAT_YEAR), - start_hour: moment().format('HH:mm') + start_date: startMoment.format(DATE_FORMAT_YEAR), + start_hour: startMoment.format('HH:mm') }; component.newData = mockEntry; component.activeEntry = mockEntry; component.setDataToUpdate(mockEntry); - const hourInTheFuture = moment().add(1, 'hours').format('HH:mm'); + const hourInTheFuture = startMoment.add(1, 'hours').format('HH:mm'); component.entryForm.patchValue({ start_hour: hourInTheFuture }); spyOn(component.entryForm, 'patchValue');