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(SideNav): #17491 increased unit test coverage #17869

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ashna000
Copy link

Closes #17491

This PR adds unit tests for the SideNav component to ensure its proper rendering and functionality. These tests ensure that this component renders with the appropriate class names, accommodates custom class names, and correctly applies additional props.

Changelog
Changed

  • Added Unit test file for SideNav.

Testing / Reviewing

  • Run the test suite to ensure that all new tests pass.
  • Review the tests for clarity and coverage.

Additional Notes
Please let me know if any further modifications are needed or if you have any questions regarding the changes.

@ashna000 ashna000 requested a review from a team as a code owner October 24, 2024 12:12
Copy link

netlify bot commented Oct 24, 2024

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

Name Link
🔨 Latest commit d35219c
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/674029d8852303000878459c
😎 Deploy Preview https://deploy-preview-17869--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 24, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit d35219c
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/674029d8df06c10008df56da
😎 Deploy Preview https://deploy-preview-17869--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 24, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit d35219c
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/674029d88a5f430008f8c182
😎 Deploy Preview https://deploy-preview-17869--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 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.45%. Comparing base (0810fa1) to head (366daff).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17869      +/-   ##
==========================================
+ Coverage   80.19%   80.45%   +0.25%     
==========================================
  Files         406      406              
  Lines       14041    14041              
  Branches     4399     4347      -52     
==========================================
+ Hits        11260    11296      +36     
+ Misses       2614     2579      -35     
+ Partials      167      166       -1     

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

@ashna000
Copy link
Author

@kennylam , @guidari Please review this PR

Copy link
Contributor

@guidari guidari left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀
I see that there are couple line that weren't tested, but I guess those lines are not possible to be tested, right?
https://app.codecov.io/gh/carbon-design-system/carbon/pull/17869/blob/packages/react/src/components/UIShell/SideNav.tsx

@ashna000 ashna000 reopened this Oct 30, 2024
@ashna000
Copy link
Author

@kennylam Please review this PR

@ashna000
Copy link
Author

ashna000 commented Nov 1, 2024

@alisonjoseph Please review this PR

Copy link
Contributor

@guidari guidari left a comment

Choose a reason for hiding this comment

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

Hey @ashna000
Looks like the Files changetestd is missing the test file for some reason. Maybe got lost in a commit.

@ashna000
Copy link
Author

ashna000 commented Nov 8, 2024

Hey @ashna000 Looks like the Files changetestd is missing the test file for some reason. Maybe got lost in a commit.

@guidari @kennylam It seems while updating the branch the test changes got missed. I have updated the tests. Please review.

@guidari
Copy link
Contributor

guidari commented Nov 8, 2024

Hey @ashna000 Do you think you could test the onMouseLeave and onMouseEnter as well?

Example in carbon:

await act(() => {
fireEvent.mouseLeave(
screen.getByRole('menuitem', { name: 'Submenu Submenu' })
);
jest.runOnlyPendingTimers();
});

Example in Stack Overflow: https://stackoverflow.com/questions/75952818/how-to-write-jest-test-case-for-moveover-and-mouseleave-for-functional-component#:~:text=simulate(%27-,mouseleave,-%27)%3B%0A%20%20%20%20expect

Screenshot 2024-11-08 at 16 19 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants