enact
enact copied to clipboard
WRQ-12037: Investigate how to mock core/platform and webos/platform
Checklist
- [x] I have read and understand the contribution guide
- [ ] A CHANGELOG entry is included
- [x] At least one test case is included for this feature or bug fix
- [x] Documentation was added or is not needed
- [ ] This is an API breaking change
Issue Resolved / Feature Added
Enact libraries like Sandstone have a few code to work on specific browser versions or specific platform environments but we don't test those logics in unit tests due to lack of mocking. So we should investigate how to mock core/platform and webos/platform in unit tests
Resolution
I added an example unit test here (https://github.com/enactjs/sandstone/pull/1605) to show how to mock core/platform or webos/platform. We can mock core/platform or webos/platform by parsing "mock userAgent". By the way, if platform information is detected once by parsing user agent, "detectedPlatform" is used after that. We can't test multiple platform in one unit test file. So I made "resetPlatformDescription" function to reset detected platform information.
Additional Considerations
Links
WRQ-12037
Comments
Enact-DCO-1.0-Signed-off-by: Jiye Kim ([email protected])
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 82.29%. Comparing base (
daf593c
) to head (5dfd1ad
). Report is 1 commits behind head on develop.
Additional details and impacted files
@@ Coverage Diff @@
## develop #3233 +/- ##
===========================================
+ Coverage 82.27% 82.29% +0.02%
===========================================
Files 152 152
Lines 7090 7090
Branches 1866 1866
===========================================
+ Hits 5833 5835 +2
+ Misses 986 985 -1
+ Partials 271 270 -1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@vJIYEv Could you update the subject and description of this PR? Thank you!