Skip to content

test(lib): cover useApi states and cancellation#226

Open
ZaaK0913-coder wants to merge 1 commit into
Agentpay-Org:mainfrom
ZaaK0913-coder:codex/useapi-hook-tests-75-20260704
Open

test(lib): cover useApi states and cancellation#226
ZaaK0913-coder wants to merge 1 commit into
Agentpay-Org:mainfrom
ZaaK0913-coder:codex/useapi-hook-tests-75-20260704

Conversation

@ZaaK0913-coder

Copy link
Copy Markdown

Summary

  • Add a focused React hook test suite for useApi.
  • Cover loading -> ok, loading -> error, generic fallback errors, null-path skip, path-change refetch, stale response ignoring, and unmount cancellation.
  • Keep the change test-only; no production code changes.

Closes #75

Validation

  • npm test -- src/lib/__tests__/useApi.test.tsx --runInBand
  • npx jest src/lib/__tests__/useApi.test.tsx --coverage --collectCoverageFrom=src/lib/useApi.ts --coverageReporters=text --coverageThreshold "{}" --runInBand (useApi.ts: 100% statements, 100% branches, 100% functions, 100% lines)
  • npx eslint src/lib/__tests__/useApi.test.tsx
  • npx prettier --check src/lib/__tests__/useApi.test.tsx

Typecheck note

  • npm run typecheck was attempted and is currently blocked by pre-existing main-branch errors outside this test-only change:
    • src/app/agents/[agent]/page.tsx: missing Breadcrumb and formatRequests
    • src/app/docs/page.tsx: missing safeHref

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 the useApi fetch state machine and cancellation

1 participant