Skip to content

Commit 07244fd

Browse files
committed
test(calc): Verified streak formulas for single day contribution(var1)
Signed-off-by: Himanshujha7 <tigmanshujah@gmail.com>
1 parent 3ed113d commit 07244fd

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

lib/calculate.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,20 @@ describe('calculateStreak', () => {
679679
expect(resultTuesday.longestStreak).toBe(2);
680680
});
681681

682+
it('verify streak formulas for single day contribution timeline (Variation 1)', () => {
683+
// 1 commit on day 11 (middle of week 2), surrounded by fully empty weeks on both sides
684+
const calendar = buildCalendar([
685+
0, 0, 0, 0, 0, 0, 0, // Week 1: empty
686+
0, 0, 0, 1, 0, 0, 0, // Week 2: single commit on day 4
687+
0, 0, 0, 0, 0, 0, 0, // Week 3: empty
688+
]);
689+
const result = calculateStreak(calendar);
690+
691+
expect(result.currentStreak).toBe(0);
692+
expect(result.longestStreak).toBe(1);
693+
expect(result.totalContributions).toBe(1);
694+
});
695+
682696
it('verify streak formulas for different starting days of the week timeline (Variation 2)', () => {
683697
// Week 1: 0, 0, 1, 1, 1, 1, 1 (Starts on Wednesday, 5 days)
684698
// Week 2: 1, 1, 1, 1, 1, 1, 1 (7 days)

0 commit comments

Comments
 (0)