Skip to content

test(axios-cqrs-client): add unit tests - #286

Merged
Komoszek merged 1 commit into
mainfrom
test/axios-cqrs-client
Jun 25, 2026
Merged

Komoszek merged 1 commit into
mainfrom
test/axios-cqrs-client

Conversation

@claude

@claude claude Bot commented Jun 25, 2026

Copy link
Copy Markdown

Requested by Sebastian Konowrocki · Slack thread

Before / After

@leancodepl/axios-cqrs-client previously had no tests. This PR adds 36 unit tests across two spec files covering both public factories:

  • mkCqrsClient — endpoint routing (query/, operation/, command/), DTO body serialization, Bearer token injection (default + custom header), absent-token handling, abort signal wiring, success wrapping (no key transform), and the createCommand.handle flow (success and mapped validation-error branches).
  • mkUncapitalizedCqrsClient — deep PascalCase→camelCase result transformation (nested objects and arrays), error passthrough (no transform on failures), command inheritance, and endpoint routing.
  • Error handling & the 401 refresh flow — status mapping for 400/403/404/422/500, network errors (AxiosError without a response), unknown non-Axios errors, ERR_CANCELED → aborted, token-refresh-and-retry success, give-up after a second 401 (isRetry marker + fresh token asserted), and refresh-failure when invalidateToken returns false.

How

Tests drive the real axios instance (with its real request/response interceptors — the unit under test) end-to-end via a custom queued adapter injected through axiosOptions, so axios itself converts non-2xx responses into the AxiosError paths the interceptor handles. Conventions mirror the sibling @leancodepl/fetch-client spec.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DXXPnGepYUGie3we1X9PTR


Generated by Claude Code

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DXXPnGepYUGie3we1X9PTR
@claude
claude Bot marked this pull request as ready for review June 25, 2026 09:35
@Komoszek
Komoszek merged commit b552d7d into main Jun 25, 2026
1 check passed
@Komoszek
Komoszek deleted the test/axios-cqrs-client branch June 25, 2026 12:45
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.

2 participants