-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(ui): add unit tests and JSDoc blocks for utility functions #135
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This also refactors calculateMaxStake for simplicity and changes its return type to `bigint`, as I've been trying to keep all Algo/asset amounts as BigInts if possible. ValidatorTable is updated to convert the value to a number before passing it to AlgoAmount. (Hopefully a future version of algokit-utils will update this utility class to support BigInts.)
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
drichar
changed the title
test(ui): add unit tests for utility functions
test(ui): add unit tests and JSDoc blocks for utility functions
May 13, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds JSDoc comment blocks to all utility functions and adds unit tests where appropriate. (Some utility functions don't really need tests – for example,
isSunsetted
, which is just an abstraction for accessing a nested property in a validator's configuration.)Writing some of these tests led to implementation detail changes in the functions/classes being tested, either making them easier to test or in a few cases resolving bugs that were exposed.
The tests and comments serve as documentation for potential contributors. Better test coverage also lays the groundwork for automerging certain types of Renovate dependency updates, reducing the time and effort required to maintain the codebase going forward.
fetchValueToVerify
The
fetchValueToVerify
function is really the only one that still needs tests, but I will handle that in a separate PR as I think it should also be refactored to handle each gating type separately. Some make network requests (as thefetch
prefix implies) which will need to be mocked. Arguably it belongs in the/src/api/contracts.ts
file and not with the utility functions for this reason.