Skip to content

Commit 8bb642a

Browse files
authored
test(calculate): verify streak formulas for different starting days of the week timeline (Variation 3) (JhaSourav07#1496) (JhaSourav07#1907)
## 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 Friday), acting as Variation 3 of the starting days timeline tests. Fixes JhaSourav07#1496 ## 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 67c187e + db82f65 commit 8bb642a

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

lib/calculate.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,37 @@ describe('calculateStreak', () => {
735735
expect(result.longestStreak).toBe(15);
736736
});
737737

738+
it('verify streak formulas for different starting days of the week timeline (Variation 3)', () => {
739+
// Week 1: 0, 0, 0, 0, 1, 1, 1 (Starts on Friday, 3 days)
740+
// Week 2: 1, 1, 1, 1, 1, 1, 1 (7 days)
741+
// Week 3: 1, 1, 1, 1, 1 // Ends on Friday (5 days)
742+
// Total continuous streak = 15 days, ending on the last day.
743+
const calendar = buildCalendar([
744+
0,
745+
0,
746+
0,
747+
0,
748+
1,
749+
1,
750+
1, // Week 1 (Starts Fri)
751+
1,
752+
1,
753+
1,
754+
1,
755+
1,
756+
1,
757+
1, // Week 2
758+
1,
759+
1,
760+
1,
761+
1,
762+
1, // Week 3 (Ends Fri)
763+
]);
764+
const result = calculateStreak(calendar);
765+
expect(result.currentStreak).toBe(15);
766+
expect(result.longestStreak).toBe(15);
767+
});
768+
738769
it('verify streak formulas for multiple weeks gaps timeline (Variation 3)', () => {
739770
// Streak 1: 5 days
740771
// Gap 1: 14 days (2 weeks of zeros)

0 commit comments

Comments
 (0)