test: add unit tests for streak utilities#3131
Open
sudeekshaballanda-hub wants to merge 1 commit into
Open
Conversation
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds unit tests for the streak utilities (
src/lib/streak-utils.ts) to increase test coverage for core streak calculation logic. This PR contains only test files and aligns with the quality sprint focus on tests, refactoring, and bug fixes.Closes # (no specific issue - this is a test improvement PR)
Type of Change
What Changed
test/streak/streak.test.ts: Added comprehensive unit tests for streak utilitiescalculateStreakfunction: Tests for consecutive days, resets on zero contributions, and unsorted datagetLongestStreakfunction: Tests for longest streak calculation with various patternsHow to Test
pnpm test test/streak/streak.test.tsExpected result:
✓ test/streak/streak.test.ts (8 tests) 15ms
✓ Streak Utilities (8)
✓ calculateStreak (4)
✓ returns 0 for empty contributions
✓ returns correct streak for consecutive days
✓ resets streak when a day has no contributions
✓ handles unsorted contributions
✓ getLongestStreak (4)
✓ returns 0 for empty contributions
✓ returns correct longest streak
✓ handles all days with contributions
Checklist
console.log, debug code, or commented-out blocksnpm run lintpasses locallynpm run type-check)Additional Context
This PR is part of my GSSoC (GirlScript Summer of Code) contribution. I'm working on improving test coverage as part of the code quality sprint mentioned in discussion #2651.
This PR contains ONLY test files - no feature code, API routes, UI components, or database migrations. It aligns with the quality sprint focus on tests, refactoring, and bug fixes.
The tests cover the core streak calculation logic used throughout the application, making the codebase more maintainable and reducing the risk of regressions.