fix: check on wrong value in RangePicker onSubmit#679
Open
AmyHuang82 wants to merge 3 commits intoreact-component:masterfrom
Open
fix: check on wrong value in RangePicker onSubmit#679AmyHuang82 wants to merge 3 commits intoreact-component:masterfrom
RangePicker onSubmit#679AmyHuang82 wants to merge 3 commits intoreact-component:masterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
yoyo837
reviewed
Oct 6, 2023
| if ( | ||
| // When user typing disabledDate with keyboard and enter, this value will be empty | ||
| !selectedValue || | ||
| !selectedValue[index] || |
Member
There was a problem hiding this comment.
Suggested change
| !selectedValue[index] || | |
| !selectedValue?.[index] || |
Author
There was a problem hiding this comment.
Member
|
Please add some test case to cover it. |
… disabledDate to start date
AmyHuang82
commented
Oct 18, 2023
Comment on lines
+590
to
+609
| it('range picker value should be empty array when typing invalid or disabledDate to start date', () => { | ||
| const onCalendarChange = jest.fn(); | ||
| const now = new Date(); | ||
| const { container } = render( | ||
| <MomentRangePicker | ||
| onCalendarChange={onCalendarChange} | ||
| disabledDate={(date) => date.month() < now.getMonth()} | ||
| />, | ||
| ); | ||
|
|
||
| openPicker(container); | ||
| fireEvent.change(container.querySelector('input'), { target: { value: '1990-1-1' } }); | ||
| closePicker(container); | ||
| expect(onCalendarChange.mock.calls).toEqual([]); | ||
|
|
||
| openPicker(container); | ||
| fireEvent.change(container.querySelector('input'), { target: { value: '2000-01-01' } }); | ||
| closePicker(container); | ||
| expect(onCalendarChange.mock.calls).toEqual([]); | ||
| }); |
Author
There was a problem hiding this comment.
Not sure if is the right place or the right way for the cover test. Any suggestions are welcome.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
RangePickerselectedValuewill be an array.So when user typing invalid or disabled start date this
!selectedValueequals to![]will be false, and then passundefinedto -disabledDatefunction.