Skip to content

Commit 7e3d6a5

Browse files
authored
test(calculate): verify aggregateCalendars handles uneven weeks (JhaSourav07#1174)
2 parents aea769d + 8e4cf53 commit 7e3d6a5

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
@@ -500,6 +500,35 @@ describe('calculateStreak — empty and sparse year edge cases', () => {
500500
// ---------- EPIC ENHANCEMENT TESTS ----------
501501

502502
describe('aggregateCalendars', () => {
503+
it('handles calendars with different numbers of weeks', () => {
504+
const cal1 = {
505+
totalContributions: 15,
506+
weeks: [
507+
{
508+
contributionDays: [{ date: '2024-01-01', contributionCount: 5 }],
509+
},
510+
{
511+
contributionDays: [{ date: '2024-01-08', contributionCount: 10 }],
512+
},
513+
],
514+
};
515+
516+
const cal2 = {
517+
totalContributions: 3,
518+
weeks: [
519+
{
520+
contributionDays: [{ date: '2024-01-01', contributionCount: 3 }],
521+
},
522+
],
523+
};
524+
525+
const result = aggregateCalendars([cal1, cal2]);
526+
527+
expect(result.weeks).toHaveLength(2);
528+
expect(result.weeks[0].contributionDays[0].contributionCount).toBe(8);
529+
expect(result.weeks[1].contributionDays[0].contributionCount).toBe(10);
530+
});
531+
503532
it('returns an empty calendar if no calendars are provided', () => {
504533
const result = aggregateCalendars([]);
505534
expect(result.totalContributions).toBe(0);

0 commit comments

Comments
 (0)