File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ( [
You can’t perform that action at this time.
0 commit comments