Skip to content

Commit 84f7336

Browse files
committed
test(calculate): add massive single-day commit spike scenario
1 parent e9da96e commit 84f7336

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

lib/calculate.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,48 @@ describe('calculateStreak', () => {
5454
expect(result.totalContributions).toBe(0);
5555
});
5656

57+
it('handles a massive single-day commit spike without affecting streak calculations', () => {
58+
const calendar = buildCalendar([
59+
1,
60+
0,
61+
1,
62+
0,
63+
1,
64+
0,
65+
1, // Week 1
66+
67+
0,
68+
0,
69+
125,
70+
0,
71+
0,
72+
0,
73+
0, // Week 2 — huge spike
74+
75+
1,
76+
1,
77+
1,
78+
1,
79+
1,
80+
0,
81+
0, // Week 3
82+
83+
1,
84+
1,
85+
1,
86+
1,
87+
1,
88+
1,
89+
1, // Week 4 — active streak ending today
90+
]);
91+
92+
const result = calculateStreak(calendar);
93+
94+
expect(result.currentStreak).toBe(7);
95+
expect(result.longestStreak).toBe(7);
96+
expect(result.totalContributions).toBe(141);
97+
});
98+
5799
it('counts an active streak when the last day has contributions', () => {
58100
// The last element represents "today" — committing today keeps the streak alive.
59101
const calendar = buildCalendar([

0 commit comments

Comments
 (0)