Skip to content

Add unit tests for the backend pagination clamping, defaults, and meta math #990

Description

@1nonlypiece

📌 Description

src/lib/backend/pagination.ts parses page/limit params and computes pagination meta, but it has no co-located test. Clamping, defaults, and meta math are unverified.

🎯 Requirements and Context

  • Cover default page/limit and clamping of out-of-range values.
  • Assert total-pages and hasNext/hasPrev meta computation.
  • Cover invalid (non-numeric) inputs falling back to defaults.

🛠️ Suggested Execution

1. Fork the repo and create a branch

git checkout -b test/backend-pagination-tests

2. Implement changes

  • src/lib/backend/__tests__/pagination.test.ts — new unit test
  • src/lib/backend/pagination.ts — read only

3. Test and commit

  • Run the suite: pnpm test (or npm test) and pnpm lint.
  • Cover edge cases: limit above max; page below 1; non-numeric params; zero total items.
  • Include test output (and a short note of any behavioural findings) in the PR.

Example commit message

test: add unit coverage for backend pagination parsing and meta

✅ Guidelines

  • Minimum 95% test coverage on the new/changed lines.
  • Clear, reviewer-friendly documentation and a small, focused diff.
  • No regressions against existing suites.
  • Timeframe: 96 hours.

🏷️ Labels

type-testing · area-frontend · MAYBE REWARDED · GRANTFOX OSS · OFFICIAL CAMPAIGN

💬 Community & Support

  • Join the CommitLabs contributor Discord to coordinate, ask questions, and get
    unblocked fast: https://discord.gg/WV7tdYkJk
  • Please introduce yourself in the channel before you start so we can avoid
    duplicate work, pair you with a reviewer, and get your PR merged quickly.
  • Maintainers actively triage this channel and aim for fast, clear, respectful
    reviews — reach out any time you're blocked.

Metadata

Metadata

Assignees

Labels

Type

Fields

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions