Page MenuHomePhabricator

[Cashtab] Include mocked chronik for render tests of useWallet hook
ClosedPublic

Authored by bytesofman on Feb 22 2024, 18:03.

Details

Summary

T3444

Include proper mocked chronik for these tests. Catches another nice case where we expect token cache to update if there is token info in tx history that is not currently in cache. Also prevents all of the API errors from these tests.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

remove test with leak issue

bytesofman added inline comments.
cashtab/src/hooks/__tests__/useWalletStorage.test.js
87 ↗(On Diff #45505)

A couple of points

1 - we do not really want to be testing state, we want to test the impact of state on the app. This is handled for this case in App.test.js
2 - Seeing cases where this test can fail due to getting state from the previous test (i.e. it will pass if run alone, fail bc gets expected result from above if not). Apparently this is a known issue with some weird troubleshooting: https://github.com/testing-library/react-testing-library/issues/716

imo the solution is to avoid testing the hook when you can better test the app.

same is true for many of the tests here. These and those in useWallet.test.js should be moved to app.test.js. will do this incrementally.

This revision is now accepted and ready to land.Feb 23 2024, 10:21