Skip to content

Commit 42016b6

Browse files
test: add weekday-only streak calculation test
1 parent f8a6a3e commit 42016b6

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

lib/calculate.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,31 @@ describe('calculateStreak', () => {
134134
expect(result.totalContributions).toBe(13);
135135
});
136136

137+
it('counts weekday-only commits from Monday through Friday without spanning weekend gaps', () => {
138+
// 2024-01-01 is a Monday. Commits happen only on weekdays across two work weeks.
139+
const calendar = buildCalendar([
140+
1,
141+
1,
142+
1,
143+
1,
144+
1,
145+
0,
146+
0, // Mon-Fri active, Sat-Sun inactive
147+
1,
148+
1,
149+
1,
150+
1,
151+
1, // Mon-Fri active again, ending on Friday
152+
]);
153+
154+
const result = calculateStreak(calendar, 'UTC', new Date('2024-01-12T12:00:00Z'));
155+
156+
expect(result.currentStreak).toBe(5);
157+
expect(result.longestStreak).toBe(5);
158+
expect(result.totalContributions).toBe(10);
159+
expect(result.todayDate).toBe('2024-01-12');
160+
});
161+
137162
it('keeps the streak alive via the grace period when only yesterday has contributions', () => {
138163
// Today is 0, but yesterday is 1 — the grace period treats the streak as still active.
139164
const calendar = buildCalendar([

0 commit comments

Comments
 (0)