sandstone icon indicating copy to clipboard operation
sandstone copied to clipboard

WRQ-12037: Investigate how to mock core/platform and webos/platform i…

Open vJIYEv opened this issue 10 months ago • 2 comments

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

We can mock "userAgent" of globalThis.navigator using "Object.defineProperty". Because core/platform and webos/platform get platform information by parsing user agent, mocking user agent is same with mocking platform. I added "InputField" unit test for example.

Additional Considerations

Links

WRQ-12037

Comments

Enact-DCO-1.0-Signed-off-by: Jiye Kim ([email protected])

vJIYEv avatar May 02 '24 08:05 vJIYEv

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 81.67%. Comparing base (335a2c1) to head (82baabf).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1605      +/-   ##
===========================================
+ Coverage    81.60%   81.67%   +0.07%     
===========================================
  Files          148      148              
  Lines         6675     6675              
  Branches      1986     1986              
===========================================
+ Hits          5447     5452       +5     
+ Misses         935      932       -3     
+ Partials       293      291       -2     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 02 '24 08:05 codecov[bot]

Travis error occurs because https://github.com/enactjs/enact/pull/3233 is not merged.

vJIYEv avatar May 13 '24 01:05 vJIYEv

This PR is very useful when I review enactjs/enact#3233 and I close this PR as we will add unit tests later with more detailed verification manners.

0x64 avatar Sep 11 '24 05:09 0x64