Skip to content

Commit 572bfcc

Browse files
committed
test(calculate): add massive single-day commit spike scenario
1 parent c24f6f4 commit 572bfcc

1 file changed

Lines changed: 18 additions & 72 deletions

File tree

lib/calculate.test.ts

Lines changed: 18 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -56,37 +56,13 @@ describe('calculateStreak', () => {
5656

5757
it('handles a massive single-day commit spike without affecting streak calculations', () => {
5858
const calendar = buildCalendar([
59-
1,
60-
0,
61-
1,
62-
0,
63-
1,
64-
0,
65-
1,
59+
1, 0, 1, 0, 1, 0, 1,
6660

67-
0,
68-
0,
69-
125,
70-
0,
71-
0,
72-
0,
73-
0,
61+
0, 0, 125, 0, 0, 0, 0,
7462

75-
1,
76-
1,
77-
1,
78-
1,
79-
1,
80-
0,
81-
0,
63+
1, 1, 1, 1, 1, 0, 0,
8264

83-
1,
84-
1,
85-
1,
86-
1,
87-
1,
88-
1,
89-
1,
65+
1, 1, 1, 1, 1, 1, 1,
9066
]);
9167

9268
const result = calculateStreak(calendar);
@@ -98,37 +74,13 @@ describe('calculateStreak', () => {
9874

9975
it('handles multiple weeks of zero contributions separating active streaks', () => {
10076
const calendar = buildCalendar([
101-
1,
102-
1,
103-
1,
104-
1,
105-
1,
106-
1,
107-
1,
77+
1, 1, 1, 1, 1, 1, 1,
10878

109-
0,
110-
0,
111-
0,
112-
0,
113-
0,
114-
0,
115-
0,
79+
0, 0, 0, 0, 0, 0, 0,
11680

117-
0,
118-
0,
119-
0,
120-
0,
121-
0,
122-
0,
123-
0,
81+
0, 0, 0, 0, 0, 0, 0,
12482

125-
1,
126-
1,
127-
1,
128-
1,
129-
1,
130-
1,
131-
1,
83+
1, 1, 1, 1, 1, 1, 1,
13284
]);
13385

13486
const result = calculateStreak(calendar);
@@ -434,17 +386,6 @@ describe('calculateStreak', () => {
434386
});
435387
});
436388

437-
it('handles massive single-day commit spike timeline', () => {
438-
const calendar = buildCalendar([
439-
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 120, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
440-
]);
441-
442-
const result = calculateStreak(calendar);
443-
444-
expect(result.currentStreak).toBe(7);
445-
expect(result.longestStreak).toBe(7);
446-
});
447-
448389
describe('calculateStreak — timezone awareness', () => {
449390
const tzCalendar = {
450391
totalContributions: 3,
@@ -666,8 +607,10 @@ describe('calculateMonthlyStats', () => {
666607
expect(result.previousMonthTotal).toBe(10);
667608
expect(result.currentMonthName).toBe('January');
668609
});
669-
// ================================================================== // ISSUE OBJECTIVE: Empty calendar passed to calculateMonthlyStats
670-
// ================================================================== it('returns zeros and does not crash when given an empty calendar', () => {
610+
// ==================================================================
611+
// ISSUE OBJECTIVE: Empty calendar passed to calculateMonthlyStats
612+
// ==================================================================
613+
it('returns zeros and does not crash when given an empty calendar', () => {
671614
const emptyCalendar = {
672615
totalContributions: 0,
673616
weeks: [],
@@ -717,8 +660,10 @@ describe('calculateStreak — empty and sparse year edge cases', () => {
717660
expect(result.totalContributions).toBe(2);
718661
});
719662

720-
// ================================================================== // ISSUE #1503 — Variation 4: Full year (52 weeks × 7 days) of 0 contributions
721-
// ================================================================== // Background: streak computation is susceptible to off-by-one errors when
663+
// ==================================================================
664+
// ISSUE #1503 — Variation 4: Full year (52 weeks × 7 days) of 0 contributions
665+
// ==================================================================
666+
// Background: streak computation is susceptible to off-by-one errors when
722667
// managing calendar offsets and date boundaries. A full year of zero commits
723668
// is the most exhaustive boundary stress-test: the loop must traverse all 364
724669
// days without incrementing either streak counter, and must not throw or return
@@ -911,7 +856,8 @@ describe('calculateWrappedStats', () => {
911856
});
912857

913858
// ISSUE OBJECTIVE: Verify weekendRatio is 100 when all commits are on weekends
914-
// ================================================================== it('returns weekendRatio === 100 when all contributions are on weekends', () => {
859+
// ==================================================================
860+
it('returns weekendRatio === 100 when all contributions are on weekends', () => {
915861
// Note: 2026-05-02 is a Saturday, 2026-05-03 is a Sunday, 2026-05-04 is a Monday
916862
const weekendCalendar = {
917863
totalContributions: 10,

0 commit comments

Comments
 (0)