File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -403,6 +403,41 @@ describe('calculateStreak — timezone awareness', () => {
403403 ] ,
404404 } ;
405405
406+ it ( 'verifies streak formulas for timezone shifts around midnight timeline' , ( ) => {
407+ const calendar = {
408+ totalContributions : 2 ,
409+ weeks : [
410+ {
411+ contributionDays : [
412+ { contributionCount : 1 , date : '2024-06-14' } ,
413+ { contributionCount : 1 , date : '2024-06-15' } ,
414+ ] ,
415+ } ,
416+ ] ,
417+ } ;
418+
419+ // Commit timeline:
420+ // 2024-06-14 23:59 UTC
421+ const beforeMidnight = new Date ( '2024-06-14T23:59:00.000Z' ) ;
422+
423+ // 2 minutes later
424+ // 2024-06-15 00:01 UTC
425+ const afterMidnight = new Date ( '2024-06-15T00:01:00.000Z' ) ;
426+
427+ const resultBefore = calculateStreak ( calendar , 'UTC' , beforeMidnight ) ;
428+
429+ const resultAfter = calculateStreak ( calendar , 'UTC' , afterMidnight ) ;
430+
431+ expect ( resultBefore . currentStreak ) . toBe ( 1 ) ;
432+ expect ( resultAfter . currentStreak ) . toBe ( 2 ) ;
433+
434+ expect ( resultBefore . longestStreak ) . toBe ( 2 ) ;
435+ expect ( resultAfter . longestStreak ) . toBe ( 2 ) ;
436+
437+ expect ( resultBefore . todayDate ) . toBe ( '2024-06-14' ) ;
438+ expect ( resultAfter . todayDate ) . toBe ( '2024-06-15' ) ;
439+ } ) ;
440+
406441 const nowUTC = new Date ( '2024-06-16T07:00:00.000Z' ) ;
407442
408443 it ( 'breaks the streak when evaluated in UTC because today and yesterday both have 0 commits' , ( ) => {
You can’t perform that action at this time.
0 commit comments