Skip to content

Commit 0e31500

Browse files
authored
test(calculate): verify streak formulas for single day contribution t… (JhaSourav07#1749)
test(calculate): verify streak formulas for single day contribution timeline (Variation 3)
2 parents 03fca35 + ec9a0ee commit 0e31500

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

lib/calculate.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,34 @@ describe('calculateStreak', () => {
608608
expect(result.longestStreak).toBe(10);
609609
expect(result.currentStreak).toBe(3);
610610
});
611+
612+
it('verify streak formulas for single day contribution timeline (Variation 3)', () => {
613+
// Simulating 1 day of commits, preceded and followed by empty weeks.
614+
// 7 empty days (1 week), 1 day of commits (1 contribution), 7 empty days (1 week)
615+
const calendar = buildCalendar([
616+
0,
617+
0,
618+
0,
619+
0,
620+
0,
621+
0,
622+
0, // Week 1: Empty week
623+
1, // 1 day of commits
624+
0,
625+
0,
626+
0,
627+
0,
628+
0,
629+
0,
630+
0, // Week 2: Empty week
631+
]);
632+
633+
const result = calculateStreak(calendar);
634+
635+
expect(result.currentStreak).toBe(0);
636+
expect(result.longestStreak).toBe(1);
637+
expect(result.totalContributions).toBe(1);
638+
});
611639
});
612640

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

0 commit comments

Comments
 (0)