Skip to content

test : add unit tests for streak calculation functions #2795

Description

@tmdeveloper007

Summary of What Needs to be Done: Add unit tests for the pure calculation functions in src/lib/streak.ts: calculateStreakFromDates, calculateCurrentStreak, calculateStreak, and todayAndYesterday.

Changes that Need to be Made: Create test/streak.test.ts (matching vitest.config.ts include pattern). Cover: calculateStreakFromDates with empty dates, single day, consecutive days (current and longest), gap breaks streak (current=0, longest preserved), wrap-around at end of THEME_OPTIONS list. calculateCurrentStreak with Set vs array input. calculateStreak with Date objects. Test timezone edge cases (UTC vs non-UTC).

Impact that it would Provide: Streak calculation is a core user-facing feature. These functions drive streak display, freeze-date handling, and timezone correctness. Tests here catch regressions before they affect user-visible streak numbers.

Hello @Priyanshu-byte-coder, please assign this issue to me (@tmdeveloper007) so I can open a focused PR.

Metadata

Metadata

Assignees

Labels

gssoc:assignedGSSoC: Issue assigned to a contributor

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions