Skip to content

Add unit tests for cursor pagination helpers in lib/utils/pagination.ts #873

Description

@Baskarayelu

📋 Description

lib/utils/pagination.ts provides validatePaginationParams (clamps limit to 1..100, default 20) and the PaginatedResult<T> contract used by remittance/bills/goals routes. The clamping and cursor handling are untested, so a regression in the limit bounds would silently affect every paginated endpoint.

This issue adds a vitest suite for the pagination helpers.

Why this matters: these helpers are shared infrastructure; a single off-by-one in the clamp affects many routes at once.

🎯 Requirements & Context

  • Test default limit (20), min clamp (1), max clamp (100), and below/above bounds.
  • Test cursor passthrough and undefined cursor handling.
  • Test PaginatedResult hasMore/nextCursor shaping if a builder exists.

Context & constraints

  • Test-only; pure functions, no mocks needed.

🛠️ Suggested Execution

git checkout -b test/pagination-utils
  • Add tests/unit/pagination.test.ts.
  • Edge cases: limit: 0, limit: 1000, negative limit, empty cursor string.
npx vitest run && npx tsc --noEmit && npm run lint
test(utils): add pagination helper unit tests

✅ Acceptance Criteria & Guidelines

Requirement Target
Clamp + default behaviour covered Required
Cursor handling covered Required
Coverage of pagination.ts ≥ 95%
tsc --noEmit, lint clean Required
Timeframe 96 hours from assignment

💬 Community & Support

Join the RemitWise contributor community on Discord: https://discord.gg/CtQuPZFMA

Comment to claim and ask questions in the channel. 🚀

Metadata

Metadata

Type

Fields

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions