-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Refactor DatePicker to use React hooks #22897
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (looks good to merge)!
It looks like the unit test failures are legitimate. The tests need to be updated due to the changes made to the component. The tests are trying to call |
Probably the easiest option is to extract It could then be exported as a named export from the file and imported into the test. The other option is to keep it internal and try to make similar assertions on the output of the component itself, but that seems a bit more complicated. |
I'm not sure to understand what I have to do… |
for testing
|
This PR will need to be rebased to fix the merge conflict and also reset the tests that got stuck 👍 |
Hello, @truchot If you have time to rebase the PR, I think we can merge your updates. |
…lass component to function component. It was already done as a part of different PR WordPress#22897. After code review it looks like the original author is not able to find time to reply or address review comments. I'm doing takeover from here and will take care of PR until it gets merged.
…36835) * Refactor DatePicker component to use react hooks and change it from class component to function component. It was already done as a part of different PR #22897. After code review it looks like the original author is not able to find time to reply or address review comments. I'm doing takeover from here and will take care of PR until it gets merged. * add changelog entry * add `onMonthPreviewed` in README.md * Remove `getMomentDate` test case Since in real word scenario, in UI we never deal with `getMomentDate` directly so in the test case we cannot write some event or simulate any behaviour that will give access to `getMomentDate` method. If we take help of `currentDate` props then test cases are already in the place. * Fix `onChangeMoment` test cases with help of `onDateChange` props * Move `getMomentDate` to a separate `utils.js` file - moved the `getMomentDate` tests under a new file, eg `test/utils.js` file - changed the `getMomentDate` unit tests to avoid rendering `DatePicker` and using enzyme * Remove extra spaces from the changelog file Co-authored-by: Marco Ciampini <[email protected]> * Descriptive documentation on `onMonthPreviewed ` props Co-authored-by: Marco Ciampini <[email protected]> Co-authored-by: Marco Ciampini <[email protected]>
Closing this PR in favour of #36835 |
Description
Related to #22890
How has this been tested?
Types of changes
Refactor to use React hooks.
Checklist: