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

Fix #4317: Fix Enzyme Test file in exclude_times_test.js and migrate it to use @testing-library/react #4318

Merged

Conversation

balajis-qb
Copy link

Closes #4317

Summary

This PR addresses the issues in the test file exclude_times_test.js and also migrated the test cases to use @testing-library/react instead of enzyme as requested by @martijnrusschen

Changes Made

  • Fix the setTime call
  • Open the <DatePicker /> component to test it, by passing the open prop
  • Use .toHaveLength(4) instead of using .not.toBeNull
  • Migrated the file to use @testing-library/react

Balaji Sridharan added 2 commits October 14, 2023 22:19
In the exclude_times_test.js file, the following modifications were made to improve the test case:

1. Added the 'open' prop to the <DatePicker /> component to ensure that it is open and its children can be tested.

2. Corrected the call to 'setTime' by providing the correct parameter format, { hour: x, minute: x }, instead of { hours: x, minutes: x }.

3. Replaced the assertion using '.not.toBeNull()' with '.toHaveLength(4)' when using '.find()'. This change makes the assertion more specific and reliable, ensuring that the test case passes only when it should.

These updates enhance the accuracy and reliability of the test case in the exclude_times_test.js file.

Closes Hacker0x01#4317
This commit updates the test case in exclude_times_test.js from using Enzyme to using @testing-library/react as requested by @martijnrusschen on [the issue Hacker0x01#4317](Hacker0x01#4317 (comment))
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ This pull request was sent to the PullRequest network.


@balajis-qb you can click here to see the review status or cancel the code review job.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

PullRequest Breakdown

Reviewable lines of change

+ 14
- 10

100% JavaScript (tests)

Type of change

Fix - These changes are likely to be fixing a bug or issue.

@codecov
Copy link

codecov bot commented Oct 14, 2023

Codecov Report

Merging #4318 (9b946f3) into main (f497ce8) will increase coverage by 0.08%.
The diff coverage is n/a.

❗ Current head 9b946f3 differs from pull request most recent head 5b82a96. Consider uploading reports for the commit 5b82a96 to get more accurate results

@@            Coverage Diff             @@
##             main    #4318      +/-   ##
==========================================
+ Coverage   96.54%   96.63%   +0.08%     
==========================================
  Files          27       27              
  Lines        2374     2374              
  Branches      966      966              
==========================================
+ Hits         2292     2294       +2     
+ Misses         82       80       -2     

see 1 file with indirect coverage changes

@martijnrusschen
Copy link
Member

Nice that was quick! looking great :) We have more usage of Enzyme, if you're up feel free to remove those as well. We need to remove Enzyme before we can safely migrate to the React 18 render methods.

@martijnrusschen
Copy link
Member

More info can be found here: #4300

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