@@ -97,39 +97,35 @@ describe('useCalendarPicker', () => {
97
97
98
98
describe ( 'Navigation handling' , ( ) => {
99
99
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 } ) ) ;
103
102
act ( ( ) => result . current . handleGoToNextMonth ( ) ) ;
104
103
105
104
expect ( result . current . displayedMonthsStartDates [ 0 ] . getMonth ( ) ) . toBe ( august ) ;
106
105
expect ( result . current . displayedMonthsStartDates [ 0 ] . getFullYear ( ) ) . toBe ( 2024 ) ;
107
106
} ) ;
108
107
109
108
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 } ) ) ;
113
111
act ( ( ) => result . current . handleGoToNextMonth ( ) ) ;
114
112
115
113
expect ( result . current . displayedMonthsStartDates [ 0 ] . getMonth ( ) ) . toBe ( january ) ;
116
114
expect ( result . current . displayedMonthsStartDates [ 0 ] . getFullYear ( ) ) . toBe ( 2025 ) ;
117
115
} ) ;
118
116
119
117
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 } ) ) ;
123
120
act ( ( ) => result . current . handleGoToPreviousMonth ( ) ) ;
124
121
125
122
expect ( result . current . displayedMonthsStartDates [ 0 ] . getMonth ( ) ) . toBe ( june ) ;
126
123
expect ( result . current . displayedMonthsStartDates [ 0 ] . getFullYear ( ) ) . toBe ( 2024 ) ;
127
124
} ) ;
128
125
129
126
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 } ) ) ;
133
129
act ( ( ) => result . current . handleGoToPreviousMonth ( ) ) ;
134
130
135
131
expect ( result . current . displayedMonthsStartDates [ 0 ] . getMonth ( ) ) . toBe ( december ) ;
0 commit comments