components
components copied to clipboard
[Bug]: DatePicker isDateEnabled function sending InvalidDates as input during unit testing.
Browser
Chrome
Package version
v3.0.501
React version
v18.0.01
Description
DatePicker-> isDateEnabled function while unit testing is sending "Invalid Date" as input. This is now happening for all dates, some dates do come up as fine. This is breaking unit tests. Input Date = Invalid Date. Error: Uncaught [TypeError: Cannot read properties of undefined (reading 'map')]
Source code
No response
Reproduction
datePickerComponent.findDatePicker().findOpenCalendarButton().click() This will trigger isDateEnabled function.
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
- [X] I checked the current issues for duplicate problems
Hello,
Could you please share a code snippet to show how the test is defined?
I tried the following:
test('isDateEnabled experiment', () => {
const dates: string[] = [];
const isDateEnabled = jest.fn().mockImplementation((date: Date) => {
dates.push(date.toISOString());
return true;
});
const { container } = render(<DatePicker {...defaultProps} isDateEnabled={isDateEnabled} />);
createWrapper(container).findDatePicker()!.findOpenCalendarButton().click();
console.log(dates);
});
The isDateEnabled
is called for calendar dates and all of the dates are defined.
Closing as the original question has been answered. Feel free to reopen if you have a follow-up ask