Skip to content

test: add unit tests for streak utilities#3131

Open
sudeekshaballanda-hub wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
sudeekshaballanda-hub:test/streak-unit-tests-only-v2
Open

test: add unit tests for streak utilities#3131
sudeekshaballanda-hub wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
sudeekshaballanda-hub:test/streak-unit-tests-only-v2

Conversation

@sudeekshaballanda-hub

Copy link
Copy Markdown

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

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 📝 Documentation update
  • ♻️ Refactor / code cleanup (no functional change)
  • ⚡ Performance improvement
  • 🔒 Security fix
  • 🧪 Tests only

What Changed

  • Created test/streak/streak.test.ts: Added comprehensive unit tests for streak utilities
    • calculateStreak function: Tests for consecutive days, resets on zero contributions, and unsorted data
    • getLongestStreak function: Tests for longest streak calculation with various patterns
    • Edge cases: Empty arrays, single-day contributions, all days with contributions

How to Test

  1. Run the unit tests:
    pnpm test test/streak/streak.test.ts
    

Expected 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

  • Linked the related issue above
  • Self-reviewed my own diff
  • No unnecessary console.log, debug code, or commented-out blocks
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Added or updated tests where applicable
  • Updated documentation / comments if behavior changed

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.

@github-actions github-actions Bot added type:testing GSSoC type bonus: tests (+10 pts) gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature labels Jul 4, 2026
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant