Skip to content

Commit 55dfc62

Browse files
authored
test(calculate): verify streak formulas for different starting days of the week timeline (Variation 2) (JhaSourav07#1486) (JhaSourav07#1905)
## Description This PR adds test coverage to verify the streak formulas when commits are made starting on different days of the week (specifically starting on Wednesday), acting as Variation 2 of the starting days timeline tests. Fixes JhaSourav07#1486 ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview N/A (Tests only) ## 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=boss477`). - [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): ...`). - [x] 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 (no raw elements, smooth animations, correct fonts). - [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 84556f6 + 6ca261b commit 55dfc62

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
@@ -488,6 +488,35 @@ describe('calculateStreak', () => {
488488
expect(resultTuesday.currentStreak).toBe(0);
489489
expect(resultTuesday.longestStreak).toBe(2);
490490
});
491+
492+
it('verify streak formulas for different starting days of the week timeline (Variation 2)', () => {
493+
// Week 1: 0, 0, 1, 1, 1, 1, 1 (Starts on Wednesday, 5 days)
494+
// Week 2: 1, 1, 1, 1, 1, 1, 1 (7 days)
495+
// Week 3: 1, 1, 1 // Ends on Wednesday (3 days)
496+
// Total continuous streak = 15 days, ending on the last day.
497+
const calendar = buildCalendar([
498+
0,
499+
0,
500+
1,
501+
1,
502+
1,
503+
1,
504+
1, // Week 1 (Starts Wed)
505+
1,
506+
1,
507+
1,
508+
1,
509+
1,
510+
1,
511+
1, // Week 2
512+
1,
513+
1,
514+
1, // Week 3 (Ends Wed)
515+
]);
516+
const result = calculateStreak(calendar);
517+
expect(result.currentStreak).toBe(15);
518+
expect(result.longestStreak).toBe(15);
519+
});
491520
});
492521

493522
it('handles massive single-day commit spike timeline', () => {

0 commit comments

Comments
 (0)