Skip to content

Commit ef85b2d

Browse files
committed
fix: TT-20 Calculate time difference when new entries added
1 parent 6b10b82 commit ef85b2d

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
@@ -513,23 +513,24 @@ describe('DetailsFieldsComponent', () => {
513513
expect(endDateInput.max).toEqual(expectedDate);
514514
});
515515

516-
fit('should return the difference if there is data in the time in and in the time out', () => {
517-
component.ngOnChanges();
518-
const StartHour = '08:00';
519-
const EndHour = '19:00';
520-
const StartDate = '2021-04-14';
521-
const EndDate = '2021-04-15';
522-
const startDateInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#start_date');
523-
const startHourInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#start_hour');
524-
const endDateInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#end_date');
525-
const endHourInput: HTMLInputElement = fixture.debugElement.nativeElement.querySelector('#end_hour');
526-
startDateInput.value = StartDate;
527-
startHourInput.value = StartHour;
528-
endDateInput.value = EndDate;
529-
endHourInput.value = EndHour;
530-
spyOn(component, 'getTimeDifference');
531-
532-
expect(component.getTimeDifference).toHaveBeenCalled();
516+
const diffParams = [
517+
{
518+
case: 'positive should return correctly diff',
519+
entryDates: {
520+
start_date: '2021-04-15',
521+
end_date: '2021-04-15',
522+
start_hour: '18:05',
523+
end_hour: '19:00',
524+
},
525+
expectedTimeDiff: '00:55',
526+
},
527+
];
528+
diffParams.map((param) => {
529+
fit(`if [start_date, start_hour] and [end_date, end_hour] diff is ${param.case}`, () => {
530+
component.entryForm.setValue({ ...formValues, ...param.entryDates });
531+
const timeDiff = component.getTimeDifference();
532+
expect(timeDiff).toBe(param.expectedTimeDiff);
533+
});
533534
});
534535

535536
/*

0 commit comments

Comments
 (0)