Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: TT-20 Calculate time difference when new entries added
  • Loading branch information
wobravo committed Apr 17, 2021
commit b33eedd2b75a3de9e15ad9d15933226ba61c47b6
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,23 @@ describe('DetailsFieldsComponent', () => {
},
expectedTimeDiff: '00:55',
},
{
case: 'negative should return 00:00',
entryDates: {
start_date: '2021-04-15',
end_date: '2021-04-14',
start_hour: '18:05',
end_hour: '17:00',
},
expectedTimeDiff: '00:00',
},
];
diffParams.map((param) => {
it(`if [start_date, start_hour] and [end_date, end_hour] diff is ${param.case}`, () => {
component.entryForm.setValue({ ...formValues, ...param.entryDates });
const timeDiff = component.getTimeDifference();

expect(timeDiff).toBe(param.expectedTimeDiff);
expect(timeDiff).toBe(param.expectedTimeDiff);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
this.end_date.setValue($event);
}

getTimeDifference() {
getTimeDifference(): string {
const startDate = moment(`${this.start_date.value} ${this.start_hour.value}`);
const endDate = moment(`${this.end_date.value} ${this.end_hour.value}`);
if (startDate <= endDate) {
Expand Down