Skip to content

test(explorer): bring src/api/explorer to 100% line coverage - #72

Merged
joeblau merged 1 commit into
mainfrom
test/coverage-cov-explorer
Jul 27, 2026
Merged

test(explorer): bring src/api/explorer to 100% line coverage#72
joeblau merged 1 commit into
mainfrom
test/coverage-cov-explorer

Conversation

@joeblau

@joeblau joeblau commented Jul 27, 2026

Copy link
Copy Markdown

What & why

Offline tests that bring src/api/explorer to 100% line coverage (tests only — no src/ changes).

  • New tests/api/explorer/_mockTransport.ts: MockExplorerTransport (records endpoint / payload / signal, serves canned responses, error injection) and MockExplorerSubscriptionTransport (records subscriptions, dispatches CustomEvent detail into the recorded listener, error injection).
  • Offline describe blocks in every method test file (blockDetails, txDetails, userDetails, explorerBlock, explorerTxs): exact request payload on the "explorer" endpoint, invalid params rejected with ValidationError before any request is sent, response / error / abort-signal passthrough, ApiRequestError on server error envelopes; for the subscriptions: duck-channel (explorerBlock_ / explorerTxs_) wiring, listener detail forwarding, onError passthrough, and unsubscribe.
  • New tests/api/explorer/client.test.ts: every ExplorerClient method delegates with the stored config.

Coverage (HL_OFFLINE=1 bun test tests/ --coverage, lcov DA lines)

File Before After
src/api/explorer/_methods/_base/_errors.ts 8/8 8/8
src/api/explorer/_methods/_base/mod.ts 2/2 2/2
src/api/explorer/_methods/blockDetails.ts 22/22 22/22
src/api/explorer/_methods/explorerBlock.ts 7/21 (33%) 20/20 (100%)
src/api/explorer/_methods/explorerTxs.ts 7/21 (33%) 20/20 (100%)
src/api/explorer/_methods/txDetails.ts 10/21 (48%) 22/22 (100%)
src/api/explorer/_methods/userDetails.ts 10/21 (48%) 22/22 (100%)
src/api/explorer/_methods total 66/116 (56.9%) 116/116 (100%)
src/api/explorer/client.ts 13/39 (33.3%) 34/34 (100%)
src/api/explorer/mod.ts 6/6 6/6

Verification

  • bun run check — all gates pass (format, lint, docs, types, ts7, jsdoc, export)
  • HL_OFFLINE=1 bun test tests/ — 1052 pass, 0 fail (32 new tests)

Type of change

  • Bug fix
  • New API method / feature
  • Schema/type update to match the Hyperliquid API
  • Breaking change
  • Tests / coverage

Add offline tests for every explorer method and the ExplorerClient
wrapper, backed by new mock transports that record endpoint, payload,
and signal, serve canned responses, and support error injection.

Per method: exact request payload on the explorer endpoint, invalid
params rejected with ValidationError before any request, response /
error / abort-signal passthrough, and ApiRequestError on server error
envelopes. For the two subscriptions: duck-channel wiring, listener
detail forwarding, onError passthrough, and unsubscribe.

Coverage (offline, HL_OFFLINE=1):
- src/api/explorer/_methods: 56.9% (66/116) -> 100% (116/116)
- src/api/explorer/client.ts: 33.3% (13/39) -> 100% (34/34)

Tests only; no src changes.
@joeblau
joeblau merged commit 4d68642 into main Jul 27, 2026
3 checks passed
@joeblau
joeblau deleted the test/coverage-cov-explorer branch July 27, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant