Skip to content

test: add unit tests for streak calculation utility functions #1069

Description

@Priyanshu-byte-coder

Testing Request

What tests are missing?
The streak calculation logic (current streak, longest streak, streak at risk) is a core feature of DevTrack but appears to lack comprehensive unit tests. These functions are business-critical — a bug here directly impacts user trust.

Proposed Tests

describe('streak calculations', () => {
  it('returns 0 for empty commit history')
  it('counts consecutive days correctly')
  it('resets streak on missed day')
  it('handles streak freeze correctly (frozen day should not break streak)')
  it('calculates longest streak from history')
  it('detects streak at risk (no commit today)')
  it('handles timezone boundaries correctly')
  it('counts today correctly if commit made after midnight')
  it('handles leap year Feb 29 correctly')
  it('handles months with 28, 29, 30, 31 days')
})

Implementation Details

  • Find streak utility functions in src/lib/ or similar
  • Create __tests__/streak.test.ts
  • Pure unit tests — no DB or API mocking needed
  • Test edge cases: year boundaries, timezone changes, DST

Acceptance Criteria

  • All 10 test cases implemented
  • 100% branch coverage for streak calculation functions
  • Tests run in < 100ms (pure unit tests)
  • Edge cases (timezones, leap years) covered

Metadata

Metadata

Assignees

Labels

good first issueGood for newcomersgssoc26GSSoC 2026 contributiongssoc:assignedGSSoC: Issue assigned to a contributorlevel:beginnerGSSoC: Beginner difficulty (20 pts)type:testingGSSoC type bonus: tests (+10 pts)

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions