Skip to content

test: cover full client resolve glue in LookupModule - #23

Merged
drichar merged 1 commit into
mainfrom
test/full-client-resolve-coverage
May 28, 2026
Merged

test: cover full client resolve glue in LookupModule#23
drichar merged 1 commit into
mainfrom
test/full-client-resolve-coverage

Conversation

@drichar

@drichar drichar commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes a coverage gap left after the @txnlab/nfd-sdk/lookup refactor (#20): the full NfdClient's resolve path was largely untested because tests/client.test.ts mocks LookupModule wholesale. The shared parsing it delegates to is already well covered (nfd-record.test.ts, registry-box.test.ts), so this adds tests for the thin fetching/glue layer specific to the full client.

  • New tests/modules/lookup.test.ts exercises the real LookupModule (no mock), following the metadata.test.ts pattern of instantiating the module directly with a mock client and the AppState fixture helpers from lookup-entry.test.ts.
  • Mocks algorand.client.getTypedAppClientById to dispatch by typed-client class, returning fakes shaped like the real NfdRegistryClient (.appClient.getBoxValue) and NfdInstanceClient (.appAddress + .appClient.getGlobalState/getBoxNames/getBoxValue).
  • Cases: name → registry-box → appID resolve; numeric-string and bigint short-circuits (assert the registry box is not read); invalid name; name not found (404); empty/missing box bytes; non-404 re-throw; and view propagation. Deliberately avoids duplicating the box-parsing/state-matrix assertions already in nfd-record.test.ts.

Coverage impact:

File Before After (stmts / branch)
src/modules/lookup.ts ~16% 100% / 100%
src/modules/base.ts ~37% 74% / 93%

Remaining base.ts gaps (requireSigner, getConstraints) are off the resolve path and out of scope here.

Test plan

  • pnpm --filter @txnlab/nfd-sdk test passes (143 tests, incl. 8 new LookupModule tests)
  • pnpm --filter @txnlab/nfd-sdk lint passes
  • pnpm --filter @txnlab/nfd-sdk typecheck passes
  • pnpm --filter @txnlab/nfd-sdk test:coverage confirms lookup.ts/base.ts resolve-path coverage rises substantially

Add tests/modules/lookup.test.ts exercising the real LookupModule
(name→appID parsing and client construction) instead of mocking it.
Raises lookup.ts to 100% and base.ts resolve-path coverage substantially.
@drichar
drichar merged commit 05ce406 into main May 28, 2026
1 check passed
@drichar
drichar deleted the test/full-client-resolve-coverage branch May 28, 2026 08:09
@txnlab-release-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant