Skip to content

Commit 0538bc0

Browse files
committed
fix tests
Signed-off-by: Clara Ni <[email protected]>
1 parent e9a932e commit 0538bc0

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

ui-core/src/components/inputs/datePicker/__tests__/useCalendarPicker.spec.ts

+8-12
Original file line numberDiff line numberDiff line change
@@ -97,39 +97,35 @@ describe('useCalendarPicker', () => {
9797

9898
describe('Navigation handling', () => {
9999
it('should navigate to the next month correctly during the year', () => {
100-
const { result } = renderHook(() =>
101-
useCalendarPicker({ initialDate: new Date(2024, july, 1) })
102-
);
100+
const initialDate = new Date(2024, july, 1);
101+
const { result } = renderHook(() => useCalendarPicker({ initialDate }));
103102
act(() => result.current.handleGoToNextMonth());
104103

105104
expect(result.current.displayedMonthsStartDates[0].getMonth()).toBe(august);
106105
expect(result.current.displayedMonthsStartDates[0].getFullYear()).toBe(2024);
107106
});
108107

109108
it('should navigate to the next month correctly at the end of the year', () => {
110-
const { result } = renderHook(() =>
111-
useCalendarPicker({ initialDate: new Date(2024, december, 1) })
112-
);
109+
const initialDate = new Date(2024, december, 1);
110+
const { result } = renderHook(() => useCalendarPicker({ initialDate }));
113111
act(() => result.current.handleGoToNextMonth());
114112

115113
expect(result.current.displayedMonthsStartDates[0].getMonth()).toBe(january);
116114
expect(result.current.displayedMonthsStartDates[0].getFullYear()).toBe(2025);
117115
});
118116

119117
it('should navigate to the previous month correctly during the year', () => {
120-
const { result } = renderHook(() =>
121-
useCalendarPicker({ initialDate: new Date(2024, july, 1) })
122-
);
118+
const initialDate = new Date(2024, july, 1);
119+
const { result } = renderHook(() => useCalendarPicker({ initialDate }));
123120
act(() => result.current.handleGoToPreviousMonth());
124121

125122
expect(result.current.displayedMonthsStartDates[0].getMonth()).toBe(june);
126123
expect(result.current.displayedMonthsStartDates[0].getFullYear()).toBe(2024);
127124
});
128125

129126
it('should navigate to the previous month correctly at the start of the year', () => {
130-
const { result } = renderHook(() =>
131-
useCalendarPicker({ initialDate: new Date(2024, january, 1) })
132-
);
127+
const initialDate = new Date(2024, january, 1);
128+
const { result } = renderHook(() => useCalendarPicker({ initialDate }));
133129
act(() => result.current.handleGoToPreviousMonth());
134130

135131
expect(result.current.displayedMonthsStartDates[0].getMonth()).toBe(december);

0 commit comments

Comments
 (0)