-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
fix: Respecting max/min opacities, and adding tests. #20555
Conversation
Codecov Report
@@ Coverage Diff @@
## master #20555 +/- ##
==========================================
- Coverage 66.75% 66.58% -0.17%
==========================================
Files 1739 1752 +13
Lines 65138 67087 +1949
Branches 6898 7448 +550
==========================================
+ Hits 43480 44667 +1187
- Misses 19908 20576 +668
- Partials 1750 1844 +94
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@@ -50,6 +50,8 @@ describe('getOpacity', () => { | |||
expect(getOpacity(100, 100, 50)).toEqual(0.05); | |||
expect(getOpacity(100, 100, 100, 0, 0.8)).toEqual(0.8); | |||
expect(getOpacity(100, 100, 50, 0, 1)).toEqual(0); | |||
expect(getOpacity(999, 100, 50, 0, 1)).toEqual(1); | |||
expect(getOpacity(-999, 100, 50, 0, 1)).toEqual(0.05); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Math.abs
inside the function will make sure result
is never negative. We can replace this test with one that passes a high minOpacity
like 0.9
and parameters that make result
be less than this value to test result < minOpacity
expect(getOpacity(-999, 100, 50, 0, 1)).toEqual(0.05); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Respecting max/min opacities, and adding tests. * revising tests * Adding missing test case for maximum coverage :) * removing unnecessary logic and test * adding another unit test for (hopefully) full coverage. * no more ternary operator * New approach with Math.min - take THAT codecov. * one more stab at making codecov happy... ignoring the file next. * lint fixes (cherry picked from commit ac8e502)
🏷️ preset:2022.25 |
* Respecting max/min opacities, and adding tests. * revising tests * Adding missing test case for maximum coverage :) * removing unnecessary logic and test * adding another unit test for (hopefully) full coverage. * no more ternary operator * New approach with Math.min - take THAT codecov. * one more stab at making codecov happy... ignoring the file next. * lint fixes (cherry picked from commit ac8e502)
SUMMARY
There was an error where calculated opacities could be over 1, or below 0. This code will only allow the opacity to go to the configured maximum or minimum.
Hat tip to @michael-s-molina for the detective work here :)
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
Unit tests included!
ADDITIONAL INFORMATION