Skip to content

test: full hook test suite with @testing-library/react - #338

Open
raymondidahor-bot wants to merge 1 commit into
dark-princezz:mainfrom
raymondidahor-bot:testing-library/react
Open

test: full hook test suite with @testing-library/react#338
raymondidahor-bot wants to merge 1 commit into
dark-princezz:mainfrom
raymondidahor-bot:testing-library/react

Conversation

@raymondidahor-bot

Copy link
Copy Markdown
Contributor

Summary

Current tests only cover utilities. This PR adds hook-level tests with mocked SDK calls for all core hooks.

Changes

Tests added

  • useFreighter — tests auto-connect, not-installed, connect(), disconnect(), signTransaction, signAuthEntry, signBlob
  • useStellarAccount — tests fetch on mount, null publicKey reset, refetch
  • useStellarBalance — tests balances/exposure, null xlmBalance edge case
  • useTransaction — tests Soroban submit + poll, classic Horizon submit, on-chain failure

Source fixes

  • Updated useFreighter for @stellar/freighter-api v2: getPublicKey replaces getAddress, simplified return types
  • Updated useTransaction, useLedgerEntry, useSorobanContract: SorobanRpcrpc for @stellar/stellar-sdk v13
  • Updated useStellarToml: StellarTomlResolverStellarToml.Resolver
  • Fixed utils/index.ts exactOptionalPropertyTypes compatibility
  • Removed unused imports, fixed any types

Bug fixes

  • Fixed vi.mock hoisting issues with vi.hoisted()
  • Fixed waitFor import from @testing-library/react-hooks (not exported in v7+)
  • Removed duplicate test blocks in useClaimableBalance.test.ts
  • Fixed broken import formatting in useStellarAccount.test.ts

CI

All three checks pass: 48 tests, lint, typecheck.

Closes #7

Add hook-level tests for useFreighter, useStellarAccount,
useStellarBalance, and useTransaction with mocked SDK calls.

Fixes:
- Fix vi.mock hoisting issues using vi.hoisted()
- Replace @testing-library/react-hooks waitFor with
  @testing-library/react waitFor
- Update useFreighter source for @stellar/freighter-api v2
  (getPublicKey replaces getAddress, simplified return types)
- Update SorobanRpc references to rpc for @stellar/stellar-sdk v13
- Fix StellarTomlResolver to StellarToml.Resolver
- Fix lint and typecheck errors (unused imports, any types, options)
- Remove duplicate test blocks in useClaimableBalance tests
- Fix broken imports in useStellarAccount tests
- All CI checks pass: 48 tests, lint, typecheck

Closes dark-princezz#7
@gloriaelishahabu

Copy link
Copy Markdown
Contributor

@raymondidahor-bot resolve conflits

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.

test: full hook test suite with @testing-library/react

2 participants