import type {CalendarProps, DateRangeProps, Range, RangeKeyDict} from 'react-date-range';
import format from 'date-fns/format';
/**
* Auto-mock of the react-date-range library for jest
*
* We mock out these components in tests because they are heavy (causes timeouts),
* difficult to interact with, and we don't need to validate their behavior.
*
* If your test is dependent on this library's functionality, you may unmock with
* jest.unmock('react-date-range')
*/
type DatePickerInputProps = {
'data-test-id': string;
date?: Date;
onChange?: (date: Date) => void;
};
type DateRangeInputsProps = {
onChange: (range: Range) => void;
range: Range;
};
function DatePickerInput({date, onChange, ...props}: DatePickerInputProps) {
return (
{
const newDate = new Date(e.target.value + 'T00:00:00');
onChange?.(newDate);
}}
{...props}
/>
);
}
/**
* Replaces the react-date-range Calendar component with a date input
*
* Example usage:
*
* const datePicker = screen.getByTestId('date-picker')
* fireEvent.change(datePicker, {target: {value: '2022-01-01'}})
*/
export function Calendar({date, onChange}: CalendarProps) {
return