Skip to content

test: add unit tests for wrapped year-summary utility functions (#2720)#2736

Open
desireddymohithreddy0925 wants to merge 2 commits into
Umbrella-io:mainfrom
desireddymohithreddy0925:test/wrapped-2720
Open

test: add unit tests for wrapped year-summary utility functions (#2720)#2736
desireddymohithreddy0925 wants to merge 2 commits into
Umbrella-io:mainfrom
desireddymohithreddy0925:test/wrapped-2720

Conversation

@desireddymohithreddy0925

Copy link
Copy Markdown

Description

Resolves #2720

This PR adds comprehensive unit testing for the pure utility functions exported from src/lib/wrapped.ts using Vitest. It ensures predictable analytics generation for the year-in-review (Wrapped) functionality.

Changes Made

  • Created test/wrapped.test.ts:
    • getYearRange: Checked past full year boundaries, current partial year bounds, and leap years.
    • calculateLongestStreak: Mocked @/lib/streak to confirm empty cases, single active days, and multiple active days.
    • getMostProductiveMonth: Verified single highest month, uniform contributions, and tie-breaking behavior (index 0).
    • getMostContributedRepo: Checked empty commit arrays, single repos, and correctly ranked multiple repositories.
    • getPeakCodingHour: Validated empty/invalid datasets, single hour entries, tie-breaks via index, and correctly formatted 12-hour AM/PM string formats.
    • calculateLanguagePercentages: Ensured single/multiple languages sort by bytes descending, respects limits, and guards against zero total bytes gracefully.
    • calculatePersonality: Guaranteed deterministic output shapes and emojis across all identities: Weekend Warrior, Night Architect, Sprint Builder, Silent Architect, and Consistency Monk.

Acceptance Criteria

  • Mocked the @/lib/streak dependency successfully for calculateLongestStreak.
  • All exported wrapped utility functions are comprehensively covered by edge-case tested scenarios.
  • The module now achieves 100% test coverage.
  • All 31 tests run successfully and deterministically with vitest.

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

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Umbrella-io — 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.

test : add unit tests for wrapped year-summary utility functions

1 participant