Skip to content

Commit

Permalink
fix: bug in customize calendar onsubmit
Browse files Browse the repository at this point in the history
  • Loading branch information
asartalo committed Jul 10, 2021
1 parent 0d2f190 commit a72c823
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/pages/calendar/CustomizeCalendarForm.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ describe('CustomizeCalendarForm', () => {
it('sends calendar data to onChange callback', () => {
expect(onChange).toHaveBeenCalledWith({ year: 2020, month: 1 });
});

it('sends calendar data to callback', () => {
userEvent.click(screen.getByRole('button', { name: /print/i }));
expect(onPrint).toHaveBeenCalledWith({ year: 2020, month: 1 });
});
});
});
});
6 changes: 2 additions & 4 deletions src/pages/calendar/CustomizeCalendarForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ function CustomizeCalendarForm(props: CustomizeCalendarFormProps): JSX.Element {

const onSubmit = (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
onPrint({
year: currentYear,
month: currentMonth,
});
onPrint(data);
};

const changeHandler = (field: string) => (event: ChangeEvent<{ value: unknown, }>) => {
Expand Down Expand Up @@ -126,6 +123,7 @@ function CustomizeCalendarForm(props: CustomizeCalendarFormProps): JSX.Element {
type="submit"
variant="contained"
color="primary"
size="large"
className={classes.submit}
>
Print Calendar
Expand Down

0 comments on commit a72c823

Please sign in to comment.