Skip to content

Commit f73f9eb

Browse files
committed
test(calculate): verify weekendRatio is 100 when all contributions are on weekends JhaSourav07#1055
1 parent 5447fd1 commit f73f9eb

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

lib/calculate.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,4 +509,27 @@ describe('calculateWrappedStats', () => {
509509
expect(result.busiestMonth).toBe('2024-01');
510510
expect(result.weekendRatio).toBe(100);
511511
});
512+
// =========================================================================
513+
// ISSUE OBJECTIVE: Verify weekendRatio is 100 when all commits are on weekends
514+
// =========================================================================
515+
it('returns weekendRatio === 100 when all contributions are on weekends', () => {
516+
// Note: 2026-05-02 is a Saturday, 2026-05-03 is a Sunday, 2026-05-04 is a Monday
517+
const weekendCalendar = {
518+
totalContributions: 10,
519+
weeks: [
520+
{
521+
contributionDays: [
522+
{ date: '2026-05-02', contributionCount: 5 }, // Saturday (Weekend)
523+
{ date: '2026-05-03', contributionCount: 5 }, // Sunday (Weekend)
524+
{ date: '2026-05-04', contributionCount: 0 }, // Monday (Weekday - 0 commits)
525+
],
526+
},
527+
],
528+
} as Parameters<typeof calculateWrappedStats>[0]; // Safely infers the exact type the function expects!
529+
530+
const result = calculateWrappedStats(weekendCalendar);
531+
532+
// Assert the ratio is exactly 100%
533+
expect(result.weekendRatio).toBe(100);
534+
});
512535
});

0 commit comments

Comments
 (0)