File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -443,6 +443,29 @@ describe('calculateMonthlyStats', () => {
443443 expect ( result . currentMonthTotal ) . toBe ( 5 ) ;
444444 expect ( result . currentMonthName ) . toBe ( 'January' ) ;
445445 } ) ;
446+ // =========================================================================
447+ // ISSUE OBJECTIVE: Empty calendar passed to calculateMonthlyStats
448+ // =========================================================================
449+ it ( 'returns zeros and does not crash when given an empty calendar' , ( ) => {
450+ const emptyCalendar = {
451+ totalContributions : 0 ,
452+ weeks : [ ] ,
453+ } as Parameters < typeof calculateMonthlyStats > [ 0 ] ;
454+
455+ const testDate = new Date ( '2026-05-29T12:00:00Z' ) ;
456+ let result : ReturnType < typeof calculateMonthlyStats > ;
457+
458+ // 1. Assert does not throw
459+ expect ( ( ) => {
460+ result = calculateMonthlyStats ( emptyCalendar , 'UTC' , testDate ) ;
461+ } ) . not . toThrow ( ) ;
462+
463+ // 2. Assert currentMonthTotal === 0
464+ expect ( result ! . currentMonthTotal ) . toBe ( 0 ) ;
465+
466+ // 3. Assert previousMonthTotal === 0
467+ expect ( result ! . previousMonthTotal ) . toBe ( 0 ) ;
468+ } ) ;
446469} ) ;
447470
448471describe ( 'calculateStreak — empty and sparse year edge cases' , ( ) => {
You can’t perform that action at this time.
0 commit comments