Skip to content

test : add tests for leaderboard utility functions #3099

Description

@tmdeveloper007

Summary of What Needs to be Done: Add unit tests for the leaderboard utility functions in src/lib/leaderboard.ts, covering validateUserConcurrency, exported constants, and any pure helper functions.

Changes that Need to be Made: Create test/leaderboard.test.ts with vitest. Cover: validateUserConcurrency returns DEFAULT (5) when env var is absent, returns clamped value when outside [1, 100] range, returns integer when valid, logs info when non-default, CACHE_REFRESH_SECONDS equals 3600, CACHE_STALE_SECONDS equals 21600, LEADERBOARD_CACHE_KEY is non-empty string, exported type constants are correct strings.

Impact that it would Provide: Leaderboard is a high-traffic feature. Testing the concurrency config and constants prevents misconfiguration that could cause rate limiting or performance degradation.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions