diff --git a/lib/calculate.test.ts b/lib/calculate.test.ts index 9eee97eb..48e2f7bd 100644 --- a/lib/calculate.test.ts +++ b/lib/calculate.test.ts @@ -517,6 +517,72 @@ describe('calculateStreak', () => { expect(result.currentStreak).toBe(15); expect(result.longestStreak).toBe(15); }); + + it('verify streak formulas for multiple weeks gaps timeline (Variation 3)', () => { + // Streak 1: 5 days + // Gap 1: 14 days (2 weeks of zeros) + // Streak 2: 10 days (longest) + // Gap 2: 21 days (3 weeks of zeros) + // Streak 3: 3 days (current) ending on the last day + const calendar = buildCalendar([ + 1, + 1, + 1, + 1, + 1, // Streak 1 (5 days) + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, // Gap 1 (14 days) + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, // Streak 2 (10 days) + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, // Gap 2 (21 days) + 1, + 1, + 1, // Streak 3 (3 days - ending on last day) + ]); + const result = calculateStreak(calendar); + expect(result.longestStreak).toBe(10); + expect(result.currentStreak).toBe(3); + }); }); it('handles massive single-day commit spike timeline', () => {