Skip to content

Commit 3257cf0

Browse files
committed
fix: TT-20 Calculate time difference when new entries added
1 parent 1166bfe commit 3257cf0

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/app/modules/shared/components/details-fields/details-fields.component.spec.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -494,23 +494,24 @@ describe('DetailsFieldsComponent', () => {
494494
expect(endDateInput.max).toEqual(expectedDate);
495495
});
496496

497-
fit('should return the difference if there is data in the time in and in the time out', () => {
498-
component.ngOnChanges();
499-
const StartHour = '08:00';
500-
const EndHour = '19:00';
501-
const StartDate = '2021-04-14';
502-
const EndDate = '2021-04-15';
503-
const startDateInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#start_date');
504-
const startHourInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#start_hour');
505-
const endDateInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#end_date');
506-
const endHourInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#end_hour');
507-
startDateInput.value = StartDate;
508-
startHourInput.value = StartHour;
509-
endDateInput.value = EndDate;
510-
endHourInput.value = EndHour;
511-
spyOn(component, 'getTimeDifference');
512-
513-
expect(component.getTimeDifference).toHaveBeenCalled();
497+
const diffParams = [
498+
{
499+
case: 'positive should return correctly diff',
500+
entryDates: {
501+
start_date: '2021-04-15',
502+
end_date: '2021-04-15',
503+
start_hour: '18:05',
504+
end_hour: '19:00',
505+
},
506+
expectedTimeDiff: '00:55',
507+
},
508+
];
509+
diffParams.map((param) => {
510+
fit(`if [start_date, start_hour] and [end_date, end_hour] diff is ${param.case}`, () => {
511+
component.entryForm.setValue({ ...formValues, ...param.entryDates });
512+
const timeDiff = component.getTimeDifference();
513+
expect(timeDiff).toBe(param.expectedTimeDiff);
514+
});
514515
});
515516

516517
/*

0 commit comments

Comments
 (0)