Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gpbl/react-day-picker
Browse files Browse the repository at this point in the history
  • Loading branch information
gpbl committed Aug 24, 2022
2 parents b26edfc + 6c9a934 commit 557cd99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,18 @@ describe.each<'single' | 'multiple' | 'range'>(['single', 'multiple', 'range'])(
'when calling "onClick" in "%s" selection mode',
(mode) => {
const activeModifiers: ActiveModifiers = {};
const dayPickerProps = { mode, onDayClick: jest.fn() };
const dayPickerProps = {
mode,
onDayClick: mockedContexts[mode].onDayClick
};
const mouseEvent = {} as React.MouseEvent<HTMLButtonElement, MouseEvent>;
const date = today;
beforeEach(() => {
setup(date, activeModifiers, dayPickerProps);
renderResult.current.onClick?.(mouseEvent);
});
test(`should have called "onDayClick" from the day picker props`, () => {
expect(dayPickerProps.onDayClick).toHaveBeenCalled();
test(`should have called "onDayClick" from the ${mode} context`, () => {
expect(dayPickerProps.onDayClick).toHaveBeenCalledTimes(1);
});
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ export function useDayEventHandlers(
multiple.onDayClick?.(date, activeModifiers, e);
} else if (isDayPickerRange(dayPicker)) {
range.onDayClick?.(date, activeModifiers, e);
} else {
dayPicker.onDayClick?.(date, activeModifiers, e);
}
dayPicker.onDayClick?.(date, activeModifiers, e);
};

const onFocus: FocusEventHandler = (e) => {
Expand Down

0 comments on commit 557cd99

Please sign in to comment.