Skip to content

Commit

Permalink
Add some description tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jfdoming committed Nov 11, 2023
1 parent 6237ca8 commit 1625ea4
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions packages/loot-core/src/shared/schedules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,86 @@ describe('recurring date description', () => {
),
).toBe('Every 2 years on May 17th');
});

it('describes intervals with limited occurrences', () => {
expect(
getRecurringDescription(
{
start: '2021-05-17',
frequency: 'weekly',
interval: 2,
endMode: 'after_n_occurrences',
endOccurrences: 2,
},
'MM/dd/yyyy',
),
).toBe('Every 2 weeks on Monday, 2 times');

expect(
getRecurringDescription(
{
start: '2021-05-17',
frequency: 'weekly',
interval: 2,
endMode: 'after_n_occurrences',
endOccurrences: 1,
},
'MM/dd/yyyy',
),
).toBe('Every 2 weeks on Monday, once');

expect(
getRecurringDescription(
{
start: '2021-05-17',
frequency: 'monthly',
interval: 2,
endMode: 'after_n_occurrences',
endOccurrences: 2,
},
'MM/dd/yyyy',
),
).toBe('Every 2 months on the 17th, 2 times');

expect(
getRecurringDescription(
{
start: '2021-05-17',
frequency: 'yearly',
interval: 2,
endMode: 'after_n_occurrences',
endOccurrences: 2,
},
'MM/dd/yyyy',
),
).toBe('Every 2 years on May 17th, 2 times');
});

it('describes intervals with an end date', () => {
expect(
getRecurringDescription(
{
start: '2021-05-17',
frequency: 'weekly',
interval: 2,
endMode: 'on_date',
endDate: '2021-06-01',
},
'MM/dd/yyyy',
),
).toBe('Every 2 weeks on Monday until 06/01/2021');

expect(
getRecurringDescription(
{
start: '2021-05-17',
frequency: 'monthly',
interval: 2,
endMode: 'on_date',
endDate: '2021-06-01',
},
'yyyy-MM-dd',
),
).toBe('Every 2 months on the 17th until 2021-06-01');
});
});

0 comments on commit 1625ea4

Please sign in to comment.