Skip to content

Commit 8e4cf53

Browse files
committed
test(calculate): verify aggregateCalendars handles uneven weeks
1 parent bcd0718 commit 8e4cf53

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

lib/calculate.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,35 @@ describe('calculateStreak — empty and sparse year edge cases', () => {
470470
// ---------- EPIC ENHANCEMENT TESTS ----------
471471

472472
describe('aggregateCalendars', () => {
473+
it('handles calendars with different numbers of weeks', () => {
474+
const cal1 = {
475+
totalContributions: 15,
476+
weeks: [
477+
{
478+
contributionDays: [{ date: '2024-01-01', contributionCount: 5 }],
479+
},
480+
{
481+
contributionDays: [{ date: '2024-01-08', contributionCount: 10 }],
482+
},
483+
],
484+
};
485+
486+
const cal2 = {
487+
totalContributions: 3,
488+
weeks: [
489+
{
490+
contributionDays: [{ date: '2024-01-01', contributionCount: 3 }],
491+
},
492+
],
493+
};
494+
495+
const result = aggregateCalendars([cal1, cal2]);
496+
497+
expect(result.weeks).toHaveLength(2);
498+
expect(result.weeks[0].contributionDays[0].contributionCount).toBe(8);
499+
expect(result.weeks[1].contributionDays[0].contributionCount).toBe(10);
500+
});
501+
473502
it('returns an empty calendar if no calendars are provided', () => {
474503
const result = aggregateCalendars([]);
475504
expect(result.totalContributions).toBe(0);

0 commit comments

Comments
 (0)