test(explorer): bring src/api/explorer to 100% line coverage - #72
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Offline tests that bring
src/api/explorerto 100% line coverage (tests only — nosrc/changes).tests/api/explorer/_mockTransport.ts:MockExplorerTransport(records endpoint / payload / signal, serves canned responses, error injection) andMockExplorerSubscriptionTransport(records subscriptions, dispatchesCustomEventdetail into the recorded listener, error injection).describeblocks in every method test file (blockDetails,txDetails,userDetails,explorerBlock,explorerTxs): exact request payload on the"explorer"endpoint, invalid params rejected withValidationErrorbefore any request is sent, response / error / abort-signal passthrough,ApiRequestErroron server error envelopes; for the subscriptions: duck-channel (explorerBlock_/explorerTxs_) wiring, listener detail forwarding,onErrorpassthrough, and unsubscribe.tests/api/explorer/client.test.ts: everyExplorerClientmethod delegates with the stored config.Coverage (
HL_OFFLINE=1 bun test tests/ --coverage, lcov DA lines)src/api/explorer/_methods/_base/_errors.tssrc/api/explorer/_methods/_base/mod.tssrc/api/explorer/_methods/blockDetails.tssrc/api/explorer/_methods/explorerBlock.tssrc/api/explorer/_methods/explorerTxs.tssrc/api/explorer/_methods/txDetails.tssrc/api/explorer/_methods/userDetails.tssrc/api/explorer/_methodstotalsrc/api/explorer/client.tssrc/api/explorer/mod.tsVerification
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