eth-ui
eth-ui copied to clipboard
🗺 Epic: unit tests for hooks in v4
Current status
We have tests that use a wrapper with a ethers/hardhat provider and a mock connector. The connector uses sinon js for mocking. There are tests for about 9 contexts and EthersAppContext.
Overall Strategy
- We want tests for all hooks.
- We want to test the functions and helpers
- useEthersContext needs tests for context key
- We want to test hooks with update options.
- I think choosing two hooks,
useTokenBalance
anduseContractReader
, and testing update options with that would be sufficient for tests that integrate hardhat and wrapper and the update options are being respected. - For other tests, we should mock
useQuery
oruseEthersUpdater
and make sure it is just getting the update options specified.
- I think choosing two hooks,
- We should test override per hook
Hook test strategy
- Tests for the functionality of the hook
- Test update options: mock
useQuery
anduseEthersUpdater
to make sure it is receiving the right values- 3 as BlockNumberInterval
- polling
- If the hook has an override: We should have two test per-hook that has the override option:
- (1) mock useEthersContext and check if it receives the key properly
- (2) make sure the hook works with the override adaptor.
- If hooks are
useTokenBalance
oruseContractReader
we should have full functionality of updates in addition to mocking as mentioned in the overall strategy. Test update options with that would be sufficient for tests that integrate hardhat and wrapper and the update options are being respected.
Code standards
- follow current standards:
- describe ('Give....')
- test ('When xxxx; then xxx')
-
useTokenBalance
is a great example!
Test issues
Add tests for Contexts
- [ ] #117
- [x] #152
Add hook tests
- [x] #116
- [x] #122
- [x] #76
- [x] #136
- [ ] #137
- [x] #138
- [ ] #139
- [x] #140
- [x] #141
- [x] #142
- [x] #145
- [x] #143
- [x] #144
- [x] #146
- [x] #147
- [ ] #148
- [x] #149
- [x] #150
- [ ] #151
Function tests
- [x] #153
- [x] #154
- [ ] #155
- [ ] #156
- [ ] #157