Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelRauber committed Jul 16, 2023
2 parents 121d1e7 + 7d29bfb commit 4f09d60
Showing 1 changed file with 54 additions and 17 deletions.
71 changes: 54 additions & 17 deletions src/app/services/time.utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,31 +87,68 @@ describe('Time Utils', () => {

describe('calculateTimeEntryGroupDuration', () => {
it('calculates correct duration with 1 item', () => {
const result = calculateTimeEntryGroupDuration([
{
duration: Duration.fromObject({ minutes: 40 }),
} as TimeEntryGroup,
]);
const result = calculateTimeEntryGroupDuration(
[
{
duration: Duration.fromObject({ minutes: 40 }),
} as TimeEntryGroup,
],
Duration.fromMillis(0),
);

expect(result.minutes).toEqual(40);
});

it('calculates correct duration with 3 item', () => {
const result = calculateTimeEntryGroupDuration([
{
duration: Duration.fromObject({ hours: 1, minutes: 40 }),
} as TimeEntryGroup,
{
duration: Duration.fromObject({ hours: 3, minutes: 40 }),
} as TimeEntryGroup,
{
duration: Duration.fromObject({ minutes: 40 }),
} as TimeEntryGroup,
]);
it('calculates correct duration with 3 items', () => {
const result = calculateTimeEntryGroupDuration(
[
{
duration: Duration.fromObject({ hours: 1, minutes: 40 }),
} as TimeEntryGroup,
{
duration: Duration.fromObject({ hours: 3, minutes: 40 }),
} as TimeEntryGroup,
{
duration: Duration.fromObject({ minutes: 40 }),
} as TimeEntryGroup,
],
Duration.fromMillis(0),
);

expect(result.minutes).toEqual(40 * 3);
expect(result.hours).toEqual(4);
});

it('calculates correct duration with a day off and no other days', () => {
const result = calculateTimeEntryGroupDuration(
[
{
isADayOff: true,
} as TimeEntryGroup,
],
Duration.fromObject({ hours: 7, minutes: 30 }),
);

expect(result.minutes).toEqual(-30);
expect(result.hours).toEqual(-7);
});

it('calculates correct duration with a day off and a normal working day', () => {
const result = calculateTimeEntryGroupDuration(
[
{
isADayOff: true,
} as TimeEntryGroup,
{
duration: Duration.fromObject({ hours: 7, minutes: 30 }),
} as TimeEntryGroup,
],
Duration.fromObject({ hours: 7, minutes: 30 }),
);

expect(result.minutes).toEqual(0);
expect(result.hours).toEqual(0);
});
});

describe('calculateRemainingAndOvertime', () => {
Expand Down

0 comments on commit 4f09d60

Please sign in to comment.