Skip to content

Commit 6ca261b

Browse files
committed
test(calculate): verify streak formulas for different starting days of the week timeline (Variation 2) (JhaSourav07#1486)
1 parent 0e4f492 commit 6ca261b

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

lib/calculate.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,35 @@ describe('calculateStreak', () => {
488488
expect(resultTuesday.currentStreak).toBe(0);
489489
expect(resultTuesday.longestStreak).toBe(2);
490490
});
491+
492+
it('verify streak formulas for different starting days of the week timeline (Variation 2)', () => {
493+
// Week 1: 0, 0, 1, 1, 1, 1, 1 (Starts on Wednesday, 5 days)
494+
// Week 2: 1, 1, 1, 1, 1, 1, 1 (7 days)
495+
// Week 3: 1, 1, 1 // Ends on Wednesday (3 days)
496+
// Total continuous streak = 15 days, ending on the last day.
497+
const calendar = buildCalendar([
498+
0,
499+
0,
500+
1,
501+
1,
502+
1,
503+
1,
504+
1, // Week 1 (Starts Wed)
505+
1,
506+
1,
507+
1,
508+
1,
509+
1,
510+
1,
511+
1, // Week 2
512+
1,
513+
1,
514+
1, // Week 3 (Ends Wed)
515+
]);
516+
const result = calculateStreak(calendar);
517+
expect(result.currentStreak).toBe(15);
518+
expect(result.longestStreak).toBe(15);
519+
});
491520
});
492521

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

0 commit comments

Comments
 (0)