Skip to content

Commit e2f7444

Browse files
committed
fix: TT-20 Calculate time difference when new entries added
1 parent 4144da6 commit e2f7444

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,23 @@ describe('DetailsFieldsComponent', () => {
505505
},
506506
expectedTimeDiff: '00:55',
507507
},
508+
{
509+
case: 'negative should return 00:00',
510+
entryDates: {
511+
start_date: '2021-04-15',
512+
end_date: '2021-04-14',
513+
start_hour: '18:05',
514+
end_hour: '17:00',
515+
},
516+
expectedTimeDiff: '00:00',
517+
},
508518
];
509519
diffParams.map((param) => {
510520
it(`if [start_date, start_hour] and [end_date, end_hour] diff is ${param.case}`, () => {
511521
component.entryForm.setValue({ ...formValues, ...param.entryDates });
512522
const timeDiff = component.getTimeDifference();
523+
524+
expect(timeDiff).toBe(param.expectedTimeDiff);
513525
expect(timeDiff).toBe(param.expectedTimeDiff);
514526
});
515527
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
128128
this.end_date.setValue($event);
129129
}
130130

131-
getTimeDifference() {
131+
getTimeDifference(): string {
132132
const startDate = moment(`${this.start_date.value} ${this.start_hour.value}`);
133133
const endDate = moment(`${this.end_date.value} ${this.end_hour.value}`);
134134
if (startDate <= endDate) {

0 commit comments

Comments
 (0)