Skip to content

Commit 2a58ebd

Browse files
committed
test(calculate): verify streak formulas for multiple weeks gaps timeline (Variation 3) (JhaSourav07#1489)
1 parent 0e4f492 commit 2a58ebd

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

lib/calculate.test.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,72 @@ describe('calculateStreak', () => {
488488
expect(resultTuesday.currentStreak).toBe(0);
489489
expect(resultTuesday.longestStreak).toBe(2);
490490
});
491+
492+
it('verify streak formulas for multiple weeks gaps timeline (Variation 3)', () => {
493+
// Streak 1: 5 days
494+
// Gap 1: 14 days (2 weeks of zeros)
495+
// Streak 2: 10 days (longest)
496+
// Gap 2: 21 days (3 weeks of zeros)
497+
// Streak 3: 3 days (current) ending on the last day
498+
const calendar = buildCalendar([
499+
1,
500+
1,
501+
1,
502+
1,
503+
1, // Streak 1 (5 days)
504+
0,
505+
0,
506+
0,
507+
0,
508+
0,
509+
0,
510+
0,
511+
0,
512+
0,
513+
0,
514+
0,
515+
0,
516+
0,
517+
0, // Gap 1 (14 days)
518+
1,
519+
1,
520+
1,
521+
1,
522+
1,
523+
1,
524+
1,
525+
1,
526+
1,
527+
1, // Streak 2 (10 days)
528+
0,
529+
0,
530+
0,
531+
0,
532+
0,
533+
0,
534+
0,
535+
0,
536+
0,
537+
0,
538+
0,
539+
0,
540+
0,
541+
0,
542+
0,
543+
0,
544+
0,
545+
0,
546+
0,
547+
0,
548+
0, // Gap 2 (21 days)
549+
1,
550+
1,
551+
1, // Streak 3 (3 days - ending on last day)
552+
]);
553+
const result = calculateStreak(calendar);
554+
expect(result.longestStreak).toBe(10);
555+
expect(result.currentStreak).toBe(3);
556+
});
491557
});
492558

493559
it('handles massive single-day commit spike timeline', () => {

0 commit comments

Comments
 (0)