📌 Description
src/hooks/useWallet.ts manages Freighter connection state (connect,
disconnect, auto-detect on mount, error handling) but has no test coverage.
This hook gates all wallet-dependent flows, so its connect/disconnect/error
transitions must be verified.
This issue adds tests for useWallet, mocking @stellar/freighter-api.
Goal: prove useWallet correctly reflects connected/disconnected/error
state across mount, connect, disconnect, and Freighter failures.
🎯 Requirements and Context
- Mock
getAddress from @stellar/freighter-api.
- Cover: auto-detect on mount when already connected;
connect populating
address/connected; result.error path setting error and clearing
connection; thrown-exception path; disconnect resetting all state.
- Use
@testing-library/react renderHook.
🛠️ Suggested Execution
1. Create a branch
git checkout -b feature/use-wallet-tests
2. Implement changes
- Add
src/hooks/__tests__/useWallet.test.ts.
- Mock the Freighter API per scenario.
3. Test and commit
- Run
npm test.
- Edge cases:
getAddress returns { error }, returns no address, throws,
resolves with an address, repeated connect calls.
Example commit message
test: cover useWallet connect/disconnect/error paths
✅ Guidelines
- Minimum 95% test coverage on the hook.
- Clear, descriptive test names.
- Timeframe: 96 hours.
🏷️ Labels
type-testing · area-frontend · MAYBE REWARDED · GRANTFOX OSS · OFFICIAL CAMPAIGN
💬 Community & Support
- Join the CommitLabs contributor Discord: https://discord.gg/WV7tdYkJk
- Introduce yourself before starting to avoid duplicate work.
- Maintainers triage actively and review fast.
📌 Description
src/hooks/useWallet.tsmanages Freighter connection state (connect,disconnect, auto-detect on mount, error handling) but has no test coverage.This hook gates all wallet-dependent flows, so its connect/disconnect/error
transitions must be verified.
This issue adds tests for
useWallet, mocking@stellar/freighter-api.🎯 Requirements and Context
getAddressfrom@stellar/freighter-api.connectpopulatingaddress/connected;result.errorpath settingerrorand clearingconnection; thrown-exception path;
disconnectresetting all state.@testing-library/reactrenderHook.🛠️ Suggested Execution
1. Create a branch
2. Implement changes
src/hooks/__tests__/useWallet.test.ts.3. Test and commit
npm test.getAddressreturns{ error }, returns no address, throws,resolves with an address, repeated connect calls.
Example commit message
✅ Guidelines
🏷️ Labels
type-testing·area-frontend·MAYBE REWARDED·GRANTFOX OSS·OFFICIAL CAMPAIGN💬 Community & Support