Skip to content
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(Dropdown): increase test coverage to 100% for Dropdown component #17785

Merged

Conversation

Shankar-CodeJunkie
Copy link
Contributor

Closes #17477

test(Dropdown): increase test coverage to 100% for Dropdown component

Changelog

New

  • Added tests for the condition readOnly true and false
  • Added test for the setTimeout functions to update states
  • Added test for the keyboard type events when readOnly was true | false

Changed

  • Moved the test file inside tests folder .

Removed

Testing / Reviewing

Test coverage has been increased to 100%, up from the previous 75%. I added mock tests for areas that were not covered in the earlier tests.

PASS packages/react/src/components/Dropdown/tests/Dropdown-test.js
Dropdown
✓ should initially render with the menu not open (19 ms)
✓ should let the user open the menu by clicking on the control (35 ms)
✓ should render with strings as items (16 ms)
✓ should render custom item components (14 ms)
✓ should render selectedItem as an element (3 ms)
✓ should render selectedItem as an element of type number (12 ms)
✓ should render when defaulItemtoString passed with null value (2 ms)
✓ should let the user select an option by clicking on the option node (43 ms)
✓ should respect readOnly prop (27 ms)
✓ should respect readOnly prop with false and respect call setTimeout function (15 ms)
✓ should respect readOnly prop with false argument and respect clear activated Timeout (9 ms)
✓ should initially render with the menu not open (1 ms)
title
✓ renders a title (2 ms)
✓ has the expected classes (2 ms)
helper
✓ renders a helper (2 ms)
✓ renders children as expected (6 ms)
should display initially selected item found in initialSelectedItem
✓ using an object type for the initialSelectedItem prop (2 ms)
✓ using a string type for the initialSelectedItem prop (1 ms)
Component API
✓ should accept a ref for the underlying button element (1 ms)
✓ should respect slug prop (3 ms)
DropdownSkeleton
Renders as expected
✓ Has the expected classes (1 ms)
Test useEffect
✓ for auto-align features (18 ms)

--------------|---------|----------|---------|---------|-------------------------------------------------------------------------

File % Stmts % Branch % Funcs % Lines Uncovered Line #s
All files 100 83.57 100 100
Dropdown.tsx 100 83.57 100 100 255-259,309-314,332,340,412-416,441-447,463,477,483-484,496,538-541,592
-------------- --------- ---------- --------- --------- -------------------------------------------------------------------------
Test Suites: 1 passed, 1 total
Tests: 22 passed, 22 total
Snapshots: 0 total
Time: 1.505 s
Ran all test suites matching /packages/react/src/components/Dropdown/tests/Dropdown-test.js/i.

Copy link

netlify bot commented Oct 17, 2024

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit ab7a3da
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/671299edc0b23400082944a5
😎 Deploy Preview https://deploy-preview-17785--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 17, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit ab7a3da
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/671299ed991e4a0008affa8b
😎 Deploy Preview https://deploy-preview-17785--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 17, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit ab7a3da
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/671299ed3ab72d0008191742
😎 Deploy Preview https://deploy-preview-17785--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Oct 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.08%. Comparing base (4312ae4) to head (ab7a3da).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17785      +/-   ##
==========================================
+ Coverage   79.72%   80.08%   +0.36%     
==========================================
  Files         406      406              
  Lines       14012    14011       -1     
  Branches     4333     4380      +47     
==========================================
+ Hits        11171    11221      +50     
+ Misses       2676     2624      -52     
- Partials      165      166       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@emyarod emyarod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

packages/react/src/components/Dropdown/Dropdown.tsx Outdated Show resolved Hide resolved
Co-authored-by: andrew <emyarod@users.noreply.github.com>
@alisonjoseph alisonjoseph added this pull request to the merge queue Oct 21, 2024
Merged via the queue into carbon-design-system:main with commit f2c4993 Oct 21, 2024
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Increase Dropdown unit test coverage
4 participants