-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
test(CornerstoneUtils): Adding unit tests for most of Cornerstone Extension utilities #5454
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
Open
ViniciusResende
wants to merge
36
commits into
OHIF:master
Choose a base branch
from
ViniciusResende:test/cornerstone-extension-utils
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
test(CornerstoneUtils): Adding unit tests for most of Cornerstone Extension utilities #5454
ViniciusResende
wants to merge
36
commits into
OHIF:master
from
ViniciusResende:test/cornerstone-extension-utils
+8,745
−68
Conversation
This file contains hidden or 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 function was using a ES6 spread for cloning the segmentation parameter, this is a shallow clone and does not apply to nested structures, therefore this was violating the parameter integrity. By using clone deep from loadash this problem is fixed.
This is a module that is inside the Cornerstone Extension that is used as a utilitary function to handle Segmentation Stats update, this commit adds a test file to it that guarantees 100% of coverage.
Since this function already has a ealy return when the segmentation isn't a truthy value (line 79), there is no reason to have another if condition for it, since it will never be satisfied.
This piece of code was removed due to the fact that it was not being used anymore by the function after its latest changes, the changes modified the way that the viewports are verified, thus removing the need for this logic. Since it was not being used anymore, I opted for removing it so it would not increase the complexity of a new reader unecessarely.
In the previous implementation when modifying an array (useLists) while iterating over it with for...of, it can cause elements to be skipped. When splice removes an element, the remaining elements shift positions, but the iterator continues from where it was, potentially skipping the next element. New approach adjust the index after the removal to avoid this problem.
✅ Deploy Preview for ohif-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Context
This PR introduces some small fixes across some of the Cornerstone Extension utility functions and a great amount of unit tests for these utility functions module. This is seen as a improvement in the code quality, enhancing the capability of detecting defects early, also these tests should be kept with care, evolving together with the files.
Changes & Results
Results
The tests are all passing and for most of them 100% of code coverage was reached. For those that do not have this value, it was evaluated that the effort to cover these lines was not compatible with the value got from covering each individual line on those specific files.
For some of the functions inside the folder tests were not added now intentionally, because they deserve their own PRs due to it's complexity.
Testing
To test the specific tests that were added one could run:
yarn test extensions/cornerstone/src/utils
This will also allow you to check the coverage.
Checklist
PR
semantic-release format and guidelines.
Code
etc.)
Public Documentation Updates
additions or removals.
Tested Environment