File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -380,6 +380,35 @@ describe('calculateStreak', () => {
380380 expect ( result . currentStreak ) . toBe ( 5 ) ;
381381 } ) ;
382382
383+ it ( 'handles weekend-only commits correctly across massive 5-day gaps' , ( ) => {
384+ // 2024-01-01 is a Monday.
385+ // We simulate a user who commits ONLY on Saturdays and Sundays.
386+ const calendar = buildCalendar ( [
387+ 0 ,
388+ 0 ,
389+ 0 ,
390+ 0 ,
391+ 0 ,
392+ 1 ,
393+ 1 , // Week 1: Mon-Fri (0), Sat-Sun (1)
394+ 0 ,
395+ 0 ,
396+ 0 ,
397+ 0 ,
398+ 0 ,
399+ 1 ,
400+ 1 , // Week 2: Mon-Fri (0), Sat-Sun (1)
401+ ] ) ;
402+
403+ const result = calculateStreak ( calendar ) ;
404+
405+ // The gap from Monday to Friday is 5 days, which far exceeds the
406+ // default grace period of 1. Therefore, the streak must break every week.
407+ expect ( result . currentStreak ) . toBe ( 2 ) ;
408+ expect ( result . longestStreak ) . toBe ( 2 ) ;
409+ expect ( result . totalContributions ) . toBe ( 4 ) ;
410+ } ) ;
411+
383412 it ( 'correctly handles leap years and non-leap years during the Feb 28 to Mar 1 transition' , ( ) => {
384413 // Helper to construct a ContributionCalendar with explicit dates
385414 const buildCustomCalendar = (
You can’t perform that action at this time.
0 commit comments