I have been writing code for a reusable date range picker which lets users set startDate and endDate and comes with an Apply button and dropdown options including ( Today, Tomorrow, This Month, etc ) for filling up the selector automatically .
While the basic functionalities are covered by the test cases written, it shows just 50% of the test cases are covered.
The uncovered line numbers are,
const onStartDateChange = value => {
setStartAndEndDate(prev, { ...prev, startDate: value });
setIsButtonDisabled(false);
};
Here, jest --coverage
shows the line setStartAndEndDate(...
not being covered by the test cases.
A little note is, the onStartDateChange is not coming from the props but resides inside the component itself.
The usage for the component is like,
<DateRangePicker enableTime onApplyClick={onApplyButtonClickMock} />
How do I cover the the function that is called when the date is picked from the calendar or ( from the dropdown ) startDate date picker is