Skip to content

test(utils): add pagination helper unit tests#912

Merged
Baskarayelu merged 1 commit into
Remitwise-Org:mainfrom
ayomidearegbeshola29-dev:test/pagination-utils
Jun 29, 2026
Merged

test(utils): add pagination helper unit tests#912
Baskarayelu merged 1 commit into
Remitwise-Org:mainfrom
ayomidearegbeshola29-dev:test/pagination-utils

Conversation

@ayomidearegbeshola29-dev

Copy link
Copy Markdown
Contributor

This PR adds comprehensive unit tests for the cursor pagination helpers in lib/utils/pagination.ts.

Changes

Bug Fix

  • Fixed to properly handle - it was being treated as falsy and defaulting to 20, but should be clamped to 1 (the minimum valid limit)

Test Coverage Added

  • Default limit behavior (defaults to 20 when not provided/undefined)
  • Min clamp (limit: 0 → 1, negative limit → 1)
  • Max clamp (limit: 1000 → 100, very large limits → 100)
  • Cursor passthrough (string cursor, empty string cursor, undefined cursor)
  • hasMore and nextCursor shaping with string and numeric IDs
  • cursor handling (valid cursor, unknown cursor, empty string cursor)
  • Property-based tests for limit clamping and cursor passthrough

Why This Matters

These helpers are shared infrastructure used by remittance/bills/goals routes. The clamping and cursor handling were previously untested, so a regression in the limit bounds would silently affect every paginated endpoint.

Acceptance Criteria Met

  • ✅ Clamp + default behaviour covered
  • ✅ Cursor handling covered
  • ✅ All 29 tests pass
  • ✅ clean (lint errors are pre-existing in other files)
  • ✅ Test-only changes, no mocks needed

closes #873

@ayomidearegbeshola29-dev ayomidearegbeshola29-dev force-pushed the test/pagination-utils branch 2 times, most recently from d7081c4 to 8675a97 Compare June 29, 2026 16:20
- Fixed validatePaginationParams to handle limit: 0 correctly (was treated as falsy)
- Added edge case tests for limit: 1000, empty string cursor, numeric IDs
- Added property-based tests for limit clamping and cursor passthrough

closes Remitwise-Org#873
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants