Skip to content

test: add comprehensive unit tests for frontend hooks (Closes #534) - #591

Open
waterWang wants to merge 1 commit into
Protocol-Guild:mainfrom
waterWang:test/hooks-unit-tests-534
Open

test: add comprehensive unit tests for frontend hooks (Closes #534)#591
waterWang wants to merge 1 commit into
Protocol-Guild:mainfrom
waterWang:test/hooks-unit-tests-534

Conversation

@waterWang

Copy link
Copy Markdown

Summary

Add comprehensive unit tests for 5 frontend hooks using vitest and @testing-library/react.

Hooks covered

Hook Tests What's tested
useWallet 6 Context consumer, connect/disconnect, signTransaction, isConnecting state, address null
useAutosave 10 localStorage save with debounce, data change re-save, error handling, cleanup on unmount, loadSavedData, clearSavedData, default delay
useFeeEstimation 5 React Query fee recommendation fetch, error state, refetch, estimateBatch success/failure
useEmployeePortal 10 Data loading on mount, error handling, pagination, filter by status/type, search, currency change reset
useWithdrawal 17 State machine flow, load anchors, anchor selection, amount validation, initiate withdrawal, polling, cancel, reset

Test infrastructure

  • vitest.config.ts — jsdom environment, globals, test setup
  • setup.ts — jest-dom matchers, react-i18next mock, cleanup on afterEach

Total: 48 tests, all passing.

…l-Guild#534)

Add unit tests for 5 custom hooks:
- useWallet: context value, connect/disconnect, signTransaction, isConnecting state
- useAutosave: localStorage save, debounce, clearSavedData, loadSavedData, error handling
- useFeeEstimation: React Query hook, fee recommendation, batch estimation, error state
- useEmployeePortal: data loading, pagination, filtering by status/type, search, currency change
- useWithdrawal: anchor selection, amount validation, initiation, polling, cancel, reset

Test infrastructure: vitest config, test setup with jest-dom matchers and i18n mock.
48 tests total, all passing.
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.

1 participant