Skip to content

Commit 35fb17e

Browse files
authored
test(calculate): verify weekendRatio is 100 when all contributions are on weekends JhaSourav07#1055 (JhaSourav07#1160)
## Description Added a new edge-case test in lib/calculate.test.ts for the calculateWrappedStats function. The test constructs a mock calendar where all non-zero contributions occur exclusively on a Saturday and Sunday (2026-05-02 and 2026-05-03), and successfully asserts that the resulting weekendRatio evaluates to exactly 100. Fixes JhaSourav07#1055 ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview <img width="938" height="372" alt="Screenshot 2026-05-29 103604" src="https://github.com/user-attachments/assets/be70674a-777a-4b66-a2b4-3479fb71601d" /> ## Checklist before requesting a review: [x] I have read the CONTRIBUTING.md file. [x] I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME). [x] I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise). [x] My commits follow the Conventional Commits format (e.g., feat(themes): ..., fix(calculate): ...). [ ] I have updated README.md if I added a new theme or URL parameter. [x] I have starred the repo. [x] I have made sure that I have only one commit to merge in this PR. [x] The SVG output matches the CommitPulse "premium quality" aesthetic standard. [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions.
2 parents e475bb9 + f73f9eb commit 35fb17e

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)