react-day-picker 8.4.1 → 8.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/index.d.ts +123 -70
  2. package/dist/index.esm.js +14 -50
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.js +122 -158
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.js +2 -0
  7. package/dist/index.min.js.map +1 -0
  8. package/dist/style.css +2 -1
  9. package/dist/style.css.d.ts +38 -37
  10. package/dist/style.css.map +1 -0
  11. package/dist/style.module.css +0 -1
  12. package/dist/style.module.css.d.ts +38 -37
  13. package/package.json +34 -32
  14. package/src/DayPicker.tsx +1 -1
  15. package/src/components/Caption/Caption.test.tsx +2 -2
  16. package/src/components/CaptionDropdowns/CaptionDropdowns.test.tsx +7 -6
  17. package/src/components/CaptionLabel/CaptionLabel.test.tsx +1 -1
  18. package/src/components/CaptionLabel/CaptionLabel.tsx +3 -3
  19. package/src/components/CaptionNavigation/CaptionNavigation.test.tsx +11 -10
  20. package/src/components/CaptionNavigation/CaptionNavigation.tsx +1 -1
  21. package/src/components/Day/Day.test.tsx +15 -16
  22. package/src/components/Day/Day.tsx +1 -1
  23. package/src/components/DayContent/DayContent.test.tsx +1 -1
  24. package/src/components/Footer/Footer.test.tsx +1 -1
  25. package/src/components/HeadRow/HeadRow.test.tsx +1 -20
  26. package/src/components/HeadRow/HeadRow.tsx +2 -6
  27. package/src/components/HeadRow/utils/getWeekdays.test.ts +1 -1
  28. package/src/components/HeadRow/utils/getWeekdays.ts +1 -5
  29. package/src/components/Month/Month.test.tsx +1 -1
  30. package/src/components/MonthsDropdown/MonthsDropdown.test.tsx +3 -2
  31. package/src/components/MonthsDropdown/MonthsDropdown.tsx +1 -3
  32. package/src/components/Navigation/Navigation.test.tsx +10 -9
  33. package/src/components/Root/Root.test.tsx +2 -3
  34. package/src/components/Row/Row.tsx +2 -1
  35. package/src/components/Table/Table.tsx +1 -1
  36. package/src/components/Table/__snapshots__/Table.test.tsx.snap +219 -210
  37. package/src/components/Table/utils/daysToMonthWeeks.ts +11 -10
  38. package/src/components/Table/utils/getMonthWeeks.ts +7 -6
  39. package/src/components/YearsDropdown/YearsDropdown.test.tsx +3 -2
  40. package/src/components/YearsDropdown/YearsDropdown.tsx +1 -3
  41. package/src/contexts/DayPicker/DayPickerContext.test.ts +55 -138
  42. package/src/contexts/DayPicker/defaultContextValues.ts +1 -1
  43. package/src/contexts/DayPicker/formatters/formatCaption.test.ts +1 -1
  44. package/src/contexts/DayPicker/formatters/formatCaption.ts +1 -2
  45. package/src/contexts/DayPicker/formatters/formatDay.ts +1 -1
  46. package/src/contexts/DayPicker/formatters/formatMonthCaption.test.ts +1 -1
  47. package/src/contexts/DayPicker/formatters/formatMonthCaption.ts +1 -1
  48. package/src/contexts/DayPicker/formatters/formatWeekdayName.test.ts +3 -3
  49. package/src/contexts/DayPicker/formatters/formatWeekdayName.ts +2 -2
  50. package/src/contexts/DayPicker/formatters/formatYearCaption.ts +1 -1
  51. package/src/contexts/DayPicker/labels/labelDay.ts +1 -1
  52. package/src/contexts/DayPicker/labels/labelWeekday.test.ts +1 -1
  53. package/src/contexts/DayPicker/labels/labelWeekday.ts +1 -1
  54. package/src/contexts/DayPicker/utils/parseFromToProps.ts +1 -3
  55. package/src/contexts/Focus/FocusContext.test.ts +35 -62
  56. package/src/contexts/Focus/FocusContext.tsx +1 -1
  57. package/src/contexts/Focus/utils/getInitialFocusTarget.ts +1 -3
  58. package/src/contexts/Focus/utils/getNextFocus.ts +12 -10
  59. package/src/contexts/Modifiers/ModifiersContext.test.ts +8 -14
  60. package/src/contexts/Modifiers/utils/getActiveModifiers.ts +1 -1
  61. package/src/contexts/Modifiers/utils/isDateInRange.ts +1 -2
  62. package/src/contexts/Modifiers/utils/isMatch.ts +1 -4
  63. package/src/contexts/Navigation/NavigationContext.test.ts +12 -17
  64. package/src/contexts/Navigation/NavigationContext.tsx +1 -3
  65. package/src/contexts/Navigation/useNavigationState.test.ts +9 -16
  66. package/src/contexts/Navigation/useNavigationState.ts +6 -4
  67. package/src/contexts/Navigation/utils/getDisplayMonths.ts +1 -3
  68. package/src/contexts/Navigation/utils/getInitialMonth.ts +1 -3
  69. package/src/contexts/Navigation/utils/getNextMonth.ts +1 -3
  70. package/src/contexts/Navigation/utils/getPreviousMonth.ts +1 -3
  71. package/src/contexts/SelectMultiple/SelectMultipleContext.test.ts +15 -20
  72. package/src/contexts/SelectMultiple/SelectMultipleContext.tsx +1 -1
  73. package/src/contexts/SelectRange/SelectRangeContext.test.ts +23 -29
  74. package/src/contexts/SelectRange/SelectRangeContext.tsx +6 -4
  75. package/src/contexts/SelectRange/utils/addToRange.ts +1 -3
  76. package/src/contexts/SelectSingle/SelectSingleContext.test.ts +18 -15
  77. package/src/hooks/useActiveModifiers/useActiveModifiers.test.tsx +9 -16
  78. package/src/hooks/useControlledValue/useControlledValue.test.ts +16 -39
  79. package/src/hooks/useDayEventHandlers/useDayEventHandlers.test.tsx +18 -78
  80. package/src/hooks/useDayRender/useDayRender.test.tsx +68 -95
  81. package/src/hooks/useDayRender/useDayRender.tsx +5 -8
  82. package/src/hooks/useInput/useInput.ts +2 -4
  83. package/src/hooks/useSelectedDays/useSelectedDays.test.ts +15 -45
  84. package/src/index.ts +1 -0
  85. package/src/style.css +0 -1
  86. package/src/style.css.d.ts +37 -36
  87. package/src/types/Labels.ts +1 -0
  88. package/dist/index.esm.d.ts +0 -1175
  89. package/dist/react-day-picker.min.js +0 -1
@@ -5,13 +5,13 @@ import userEvent from '@testing-library/user-event';
5
5
  import { setMonth, setYear } from 'date-fns';
6
6
  import { DayPickerProps } from 'DayPicker';
7
7
 
8
+ import { customRender } from 'test/render';
8
9
  import {
9
10
  getMonthDropdown,
10
11
  getYearDropdown,
11
12
  queryMonthDropdown,
12
13
  queryYearDropdown
13
- } from 'test/po';
14
- import { customRender } from 'test/render';
14
+ } from 'test/selectors';
15
15
  import { freezeBeforeAll } from 'test/utils';
16
16
 
17
17
  import { CaptionProps } from 'components/Caption';
@@ -25,6 +25,7 @@ const toYear = 2025;
25
25
 
26
26
  freezeBeforeAll(today);
27
27
 
28
+ const user = userEvent.setup();
28
29
  function setup(props: CaptionProps, dayPickerProps?: DayPickerProps) {
29
30
  customRender(<CaptionDropdowns {...props} />, dayPickerProps);
30
31
  }
@@ -85,8 +86,8 @@ describe('when a month is selected', () => {
85
86
  });
86
87
  describe('from the months drop-down', () => {
87
88
  const newMonth = setMonth(today, 0);
88
- beforeEach(() => {
89
- userEvent.selectOptions(
89
+ beforeEach(async () => {
90
+ await user.selectOptions(
90
91
  getMonthDropdown(),
91
92
  newMonth.getMonth().toString()
92
93
  );
@@ -97,8 +98,8 @@ describe('when a month is selected', () => {
97
98
  });
98
99
  describe('from the years drop-down', () => {
99
100
  const newYear = setYear(today, 2022);
100
- beforeEach(() => {
101
- userEvent.selectOptions(
101
+ beforeEach(async () => {
102
+ await user.selectOptions(
102
103
  getYearDropdown(),
103
104
  newYear.getFullYear().toString()
104
105
  );
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
 
3
- import { getMonthCaption } from 'test/po';
4
3
  import { customRender } from 'test/render';
4
+ import { getMonthCaption } from 'test/selectors';
5
5
  import { freezeBeforeAll } from 'test/utils';
6
6
 
7
7
  import { CaptionLabel } from './CaptionLabel';
@@ -19,14 +19,14 @@ export function CaptionLabel(props: CaptionLabelProps): JSX.Element {
19
19
  formatters: { formatCaption }
20
20
  } = useDayPicker();
21
21
  return (
22
- <h2
22
+ <div
23
23
  className={classNames.caption_label}
24
24
  style={styles.caption_label}
25
25
  aria-live="polite"
26
- aria-atomic="true"
26
+ role="presentation"
27
27
  id={props.id}
28
28
  >
29
29
  {formatCaption(props.displayMonth, { locale })}
30
- </h2>
30
+ </div>
31
31
  );
32
32
  }
@@ -5,14 +5,14 @@ import userEvent from '@testing-library/user-event';
5
5
  import { addMonths } from 'date-fns';
6
6
  import { DayPickerProps } from 'DayPicker';
7
7
 
8
+ import { customRender } from 'test/render';
8
9
  import {
9
10
  getMonthCaption,
10
11
  getNextButton,
11
12
  getPrevButton,
12
13
  queryNextButton,
13
14
  queryPrevButton
14
- } from 'test/po';
15
- import { customRender } from 'test/render';
15
+ } from 'test/selectors';
16
16
  import { freezeBeforeAll } from 'test/utils';
17
17
 
18
18
  import { CaptionProps } from 'components/Caption';
@@ -24,6 +24,7 @@ const today = new Date(2021, 8);
24
24
 
25
25
  freezeBeforeAll(today);
26
26
 
27
+ const user = userEvent.setup();
27
28
  function setup(props: CaptionProps, dayPickerProps?: DayPickerProps) {
28
29
  customRender(<CaptionNavigation {...props} />, dayPickerProps);
29
30
  }
@@ -115,9 +116,9 @@ describe('when rendered', () => {
115
116
  onMonthChange: jest.fn()
116
117
  };
117
118
  const previousMonth = addMonths(today, -1);
118
- beforeEach(() => {
119
+ beforeEach(async () => {
119
120
  customRender(<CaptionNavigation displayMonth={today} />, testContext);
120
- userEvent.click(getPrevButton());
121
+ await user.click(getPrevButton());
121
122
  });
122
123
  test('should call the `onMonthChange` callback', () => {
123
124
  expect(testContext.onMonthChange).toHaveBeenCalledWith(previousMonth);
@@ -129,9 +130,9 @@ describe('when rendered', () => {
129
130
  fromDate: today,
130
131
  onMonthChange: jest.fn()
131
132
  };
132
- beforeEach(() => {
133
+ beforeEach(async () => {
133
134
  customRender(<CaptionNavigation displayMonth={today} />, testContext);
134
- userEvent.click(getPrevButton());
135
+ await user.click(getPrevButton());
135
136
  });
136
137
  test('should call the `onMonthChange` callback', () => {
137
138
  expect(testContext.onMonthChange).not.toHaveBeenCalled();
@@ -146,9 +147,9 @@ describe('when rendered', () => {
146
147
  onMonthChange: jest.fn()
147
148
  };
148
149
  const nextMonth = addMonths(today, 1);
149
- beforeEach(() => {
150
+ beforeEach(async () => {
150
151
  customRender(<CaptionNavigation displayMonth={today} />, testContext);
151
- userEvent.click(getNextButton());
152
+ await user.click(getNextButton());
152
153
  });
153
154
  test('should call the `onMonthChange` callback', () => {
154
155
  expect(testContext.onMonthChange).toHaveBeenCalledWith(nextMonth);
@@ -160,9 +161,9 @@ describe('when rendered', () => {
160
161
  toDate: today,
161
162
  onMonthChange: jest.fn()
162
163
  };
163
- beforeEach(() => {
164
+ beforeEach(async () => {
164
165
  customRender(<CaptionNavigation displayMonth={today} />, testContext);
165
- userEvent.click(getNextButton());
166
+ await user.click(getNextButton());
166
167
  });
167
168
  test('should call the `onMonthChange` callback', () => {
168
169
  expect(testContext.onMonthChange).not.toHaveBeenCalled();
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import isSameMonth from 'date-fns/isSameMonth';
3
+ import { isSameMonth } from 'date-fns';
4
4
 
5
5
  import { CaptionProps } from 'components/Caption/Caption';
6
6
  import { CaptionLabel } from 'components/CaptionLabel';
@@ -13,11 +13,6 @@ import { Day, DayProps } from './Day';
13
13
  const today = new Date(2021, 8);
14
14
 
15
15
  freezeBeforeAll(today);
16
- let container: HTMLElement;
17
- function setup(props: DayProps, dayPickerProps?: DayPickerProps) {
18
- const view = customRender(<Day {...props} />, dayPickerProps);
19
- container = view.container;
20
- }
21
16
 
22
17
  const date = today;
23
18
  const displayMonth = today;
@@ -31,19 +26,21 @@ describe('when the day to render has an hidden modifier', () => {
31
26
  modifiers: { hidden: date }
32
27
  };
33
28
  beforeEach(() => {
34
- setup(props, dayPickerProps);
29
+ customRender(<Day {...props} />, dayPickerProps);
35
30
  });
36
- test('should render an empty element', () => {
37
- expect(container).toBeEmptyDOMElement();
31
+ test('should render an empty grid cell', () => {
32
+ const cell = screen.getByRole('gridcell');
33
+ expect(cell).toBeEmptyDOMElement();
38
34
  });
39
35
  });
40
36
  describe('when a no selection mode and no "onDayClick"', () => {
41
37
  const dayPickerProps: DayPickerProps = { mode: 'default' };
42
38
  beforeEach(() => {
43
- setup(props, dayPickerProps);
39
+ customRender(<Day {...props} />, dayPickerProps);
44
40
  });
45
41
  test('should render a div', () => {
46
- expect(container.firstChild?.nodeName).toBe('DIV');
42
+ const cell = screen.getByRole('gridcell');
43
+ expect(cell.nodeName).toBe('DIV');
47
44
  });
48
45
  });
49
46
 
@@ -52,11 +49,12 @@ describe('when a selection mode is set', () => {
52
49
  mode: 'single'
53
50
  };
54
51
  beforeEach(() => {
55
- setup(props, dayPickerProps);
52
+ customRender(<Day {...props} />, dayPickerProps);
56
53
  });
57
54
  test('should render a button named "day"', () => {
58
- expect(container.firstChild?.nodeName).toBe('BUTTON');
59
- expect(container.firstChild).toHaveAttribute('name', 'day');
55
+ const cell = screen.getByRole('gridcell');
56
+ expect(cell.nodeName).toBe('BUTTON');
57
+ expect(cell).toHaveAttribute('name', 'day');
60
58
  });
61
59
  });
62
60
 
@@ -65,10 +63,11 @@ describe('when "onDayClick" is present', () => {
65
63
  onDayClick: jest.fn()
66
64
  };
67
65
  beforeEach(() => {
68
- setup(props, dayPickerProps);
66
+ customRender(<Day {...props} />, dayPickerProps);
69
67
  });
70
68
  test('should render a button', () => {
71
- expect(container.firstChild?.nodeName).toBe('BUTTON');
69
+ const cell = screen.getByRole('gridcell');
70
+ expect(cell.nodeName).toBe('BUTTON');
72
71
  });
73
72
  });
74
73
 
@@ -77,7 +76,7 @@ describe('when using a custom DayContent component', () => {
77
76
  DayContent: () => <>Custom DayContent</>
78
77
  };
79
78
  beforeEach(() => {
80
- setup(props, { components });
79
+ customRender(<Day {...props} />, { components });
81
80
  });
82
81
  test('it should render the custom component instead', () => {
83
82
  expect(screen.getByText('Custom DayContent')).toBeInTheDocument();
@@ -21,7 +21,7 @@ export function Day(props: DayProps): JSX.Element {
21
21
  const dayRender = useDayRender(props.date, props.displayMonth, buttonRef);
22
22
 
23
23
  if (dayRender.isHidden) {
24
- return <></>;
24
+ return <div role="gridcell"></div>;
25
25
  }
26
26
  if (!dayRender.isButton) {
27
27
  return <div {...dayRender.divProps} />;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import es from 'date-fns/locale/es';
3
+ import { es } from 'date-fns/locale';
4
4
  import { DayPickerProps } from 'DayPicker';
5
5
 
6
6
  import { customRender } from 'test/render';
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
 
3
- import { getTableFooter, queryTableFooter } from 'test/po';
4
3
  import { customRender } from 'test/render';
4
+ import { getTableFooter, queryTableFooter } from 'test/selectors';
5
5
 
6
6
  import { Footer } from './Footer';
7
7
 
@@ -1,16 +1,11 @@
1
1
  import React from 'react';
2
2
 
3
- import { RenderResult, screen } from '@testing-library/react';
3
+ import { RenderResult } from '@testing-library/react';
4
4
  import { DayPickerProps } from 'DayPicker';
5
5
 
6
6
  import { customRender } from 'test/render';
7
7
 
8
- import { defaultClassNames } from 'contexts/DayPicker/defaultClassNames';
9
- import { formatWeekdayName } from 'contexts/DayPicker/formatters';
10
- import { labelWeekday } from 'contexts/DayPicker/labels';
11
-
12
8
  import { HeadRow } from './HeadRow';
13
- import { getWeekdays } from './utils/getWeekdays';
14
9
 
15
10
  let container: HTMLElement;
16
11
  let view: RenderResult;
@@ -65,20 +60,6 @@ describe('when rendered', () => {
65
60
  expect(el).toHaveClass(dayPickerProps.classNames.head_cell);
66
61
  });
67
62
  });
68
- test('the formatted weekday name should be ARIA-hidden', () => {
69
- const weekdays = getWeekdays();
70
- weekdays.forEach((weekday) => {
71
- const text = formatWeekdayName(weekday);
72
- expect(screen.getByText(text)).toHaveAttribute('aria-hidden', 'true');
73
- });
74
- });
75
- test('the label should not be visible', () => {
76
- const weekdays = getWeekdays();
77
- weekdays.forEach((weekday) => {
78
- const text = labelWeekday(weekday);
79
- expect(screen.getByText(text)).toHaveClass(defaultClassNames.vhidden);
80
- });
81
- });
82
63
  });
83
64
 
84
65
  describe('when showing the week numbers', () => {
@@ -36,13 +36,9 @@ export function HeadRow(): JSX.Element {
36
36
  scope="col"
37
37
  className={classNames.head_cell}
38
38
  style={styles.head_cell}
39
+ aria-label={labelWeekday(weekday, { locale })}
39
40
  >
40
- <span aria-hidden={true}>
41
- {formatWeekdayName(weekday, { locale })}
42
- </span>
43
- <span className={classNames.vhidden}>
44
- {labelWeekday(weekday, { locale })}
45
- </span>
41
+ {formatWeekdayName(weekday, { locale })}
46
42
  </th>
47
43
  ))}
48
44
  </tr>
@@ -1,4 +1,4 @@
1
- import es from 'date-fns/locale/es';
1
+ import { es } from 'date-fns/locale';
2
2
 
3
3
  import { freezeBeforeAll } from 'test/utils';
4
4
 
@@ -1,8 +1,4 @@
1
- import addDays from 'date-fns/addDays';
2
- import startOfISOWeek from 'date-fns/startOfISOWeek';
3
- import startOfWeek from 'date-fns/startOfWeek';
4
-
5
- import type { Locale } from 'date-fns';
1
+ import { addDays, Locale, startOfISOWeek, startOfWeek } from 'date-fns';
6
2
 
7
3
  /**
8
4
  * Generate a series of 7 days, starting from the week, to use for formatting
@@ -3,8 +3,8 @@ import React from 'react';
3
3
  import { screen } from '@testing-library/react';
4
4
  import { DayPickerProps } from 'DayPicker';
5
5
 
6
- import { getMonthCaption, getMonthGrid } from 'test/po';
7
6
  import { customRender } from 'test/render';
7
+ import { getMonthCaption, getMonthGrid } from 'test/selectors';
8
8
 
9
9
  import { CustomComponents } from 'types/DayPickerBase';
10
10
 
@@ -18,6 +18,7 @@ let root: HTMLDivElement;
18
18
  let options: HTMLCollectionOf<HTMLOptionElement> | undefined;
19
19
  let select: HTMLSelectElement | null;
20
20
 
21
+ const user = userEvent.setup();
21
22
  function setup(props: MonthsDropdownProps, dayPickerProps?: DayPickerProps) {
22
23
  const view = customRender(<MonthsDropdown {...props} />, dayPickerProps);
23
24
  root = view.container.firstChild as HTMLDivElement;
@@ -98,8 +99,8 @@ describe('when "fromDate" and "toDate" are not in the same year', () => {
98
99
  });
99
100
 
100
101
  describe('when the dropdown changes', () => {
101
- beforeEach(() => {
102
- if (select) userEvent.selectOptions(select, 'February');
102
+ beforeEach(async () => {
103
+ if (select) await user.selectOptions(select, 'February');
103
104
  });
104
105
  test('should fire the "onChange" event handler', () => {
105
106
  const expectedMonth = new Date(2015, 1, 1);
@@ -1,8 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import isSameYear from 'date-fns/isSameYear';
4
- import setMonth from 'date-fns/setMonth';
5
- import startOfMonth from 'date-fns/startOfMonth';
3
+ import { isSameYear, setMonth, startOfMonth } from 'date-fns';
6
4
 
7
5
  import { Dropdown } from 'components/Dropdown';
8
6
  import { useDayPicker } from 'contexts/DayPicker';
@@ -3,13 +3,14 @@ import React from 'react';
3
3
  import userEvent from '@testing-library/user-event';
4
4
  import { DayPickerProps } from 'DayPicker';
5
5
 
6
- import { getNextButton, getPrevButton } from 'test/po';
7
6
  import { customRender } from 'test/render';
7
+ import { getNextButton, getPrevButton } from 'test/selectors';
8
8
 
9
9
  import { Navigation, NavigationProps } from './Navigation';
10
10
 
11
11
  let root: HTMLElement;
12
12
 
13
+ const user = userEvent.setup();
13
14
  function setup(props: NavigationProps, dayPickerProps?: DayPickerProps) {
14
15
  const view = customRender(<Navigation {...props} />, dayPickerProps);
15
16
  root = view.container.firstChild as HTMLElement;
@@ -62,16 +63,16 @@ describe('when rendered', () => {
62
63
  test('the next button should be named "next-month"', () => {
63
64
  expect(getNextButton()).toHaveAttribute('name', 'next-month');
64
65
  });
65
- beforeEach(() => {
66
- userEvent.click(getPrevButton());
66
+ beforeEach(async () => {
67
+ await user.click(getPrevButton());
67
68
  });
68
69
  test('should call "onPreviousClick"', () => {
69
70
  expect(props.onPreviousClick).toHaveBeenCalled();
70
71
  });
71
72
 
72
73
  describe('when clicking the next button', () => {
73
- beforeEach(() => {
74
- userEvent.click(getNextButton());
74
+ beforeEach(async () => {
75
+ await user.click(getNextButton());
75
76
  });
76
77
  test('should call "onNextClick"', () => {
77
78
  expect(props.onNextClick).toHaveBeenCalled();
@@ -93,16 +94,16 @@ describe('when in right-to-left direction', () => {
93
94
  });
94
95
 
95
96
  describe('when clicking the previous button', () => {
96
- beforeEach(() => {
97
- userEvent.click(getPrevButton());
97
+ beforeEach(async () => {
98
+ await user.click(getPrevButton());
98
99
  });
99
100
  test('should call "onPreviousClick"', () => {
100
101
  expect(props.onPreviousClick).toHaveBeenCalled();
101
102
  });
102
103
  });
103
104
  describe('when clicking the next button', () => {
104
- beforeEach(() => {
105
- userEvent.click(getNextButton());
105
+ beforeEach(async () => {
106
+ await user.click(getNextButton());
106
107
  });
107
108
  test('should call "onNextClick"', () => {
108
109
  expect(props.onNextClick).toHaveBeenCalled();
@@ -4,9 +4,8 @@ import { RenderResult } from '@testing-library/react';
4
4
  import { addDays } from 'date-fns';
5
5
  import { DayPickerProps } from 'DayPicker';
6
6
 
7
- import { focusDay } from 'test/actions';
8
- import { getDayButton, queryMonthGrids } from 'test/po';
9
7
  import { customRender } from 'test/render';
8
+ import { getDayButton, queryMonthGrids } from 'test/selectors';
10
9
  import { freezeBeforeAll } from 'test/utils';
11
10
 
12
11
  import { defaultClassNames } from 'contexts/DayPicker/defaultClassNames';
@@ -103,7 +102,7 @@ describe('when "initialFocus" is set', () => {
103
102
  });
104
103
  describe('when a new day is focused', () => {
105
104
  beforeEach(() => {
106
- focusDay(addDays(today, 1));
105
+ getDayButton(addDays(today, 1)).focus();
107
106
  });
108
107
  describe('and the calendar is rerendered', () => {
109
108
  test.todo('should focus the new day');
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import getUnixTime from 'date-fns/getUnixTime';
3
+ import { getUnixTime } from 'date-fns';
4
4
 
5
5
  import { Day } from 'components/Day';
6
6
  import { WeekNumber } from 'components/WeekNumber';
@@ -42,6 +42,7 @@ export function Row(props: RowProps): JSX.Element {
42
42
  className={classNames.cell}
43
43
  style={styles.cell}
44
44
  key={getUnixTime(date)}
45
+ role="presentation"
45
46
  >
46
47
  <DayComponent displayMonth={props.displayMonth} date={date} />
47
48
  </td>
@@ -48,7 +48,7 @@ export function Table(props: TableProps): JSX.Element {
48
48
  aria-labelledby={props['aria-labelledby']}
49
49
  >
50
50
  {!hideHead && <HeadComponent />}
51
- <tbody className={classNames.tbody} style={styles.tbody}>
51
+ <tbody className={classNames.tbody} style={styles.tbody} role="rowgroup">
52
52
  {weeks.map((week) => (
53
53
  <RowComponent
54
54
  displayMonth={props.displayMonth}