@@ -11,21 +11,13 @@ describe('useCounter', () => {
1111 } ) ;
1212
1313 it ( 'should initialize with provided initial value' , ( ) => {
14- const { result } = renderHook ( ( ) =>
15- useCounter ( {
16- initialValue : 10 ,
17- } )
18- ) ;
14+ const { result } = renderHook ( ( ) => useCounter ( 10 ) ) ;
1915
2016 expect ( result . current . count ) . toBe ( 10 ) ;
2117 } ) ;
2218
2319 it ( 'should increment the counter' , ( ) => {
24- const { result } = renderHook ( ( ) =>
25- useCounter ( {
26- initialValue : 5 ,
27- } )
28- ) ;
20+ const { result } = renderHook ( ( ) => useCounter ( 5 ) ) ;
2921
3022 act ( ( ) => {
3123 result . current . increment ( ) ;
@@ -35,11 +27,7 @@ describe('useCounter', () => {
3527 } ) ;
3628
3729 it ( 'should decrement the counter' , ( ) => {
38- const { result } = renderHook ( ( ) =>
39- useCounter ( {
40- initialValue : 5 ,
41- } )
42- ) ;
30+ const { result } = renderHook ( ( ) => useCounter ( 5 ) ) ;
4331
4432 act ( ( ) => {
4533 result . current . decrement ( ) ;
@@ -49,11 +37,7 @@ describe('useCounter', () => {
4937 } ) ;
5038
5139 it ( 'should reset the counter to initial value' , ( ) => {
52- const { result } = renderHook ( ( ) =>
53- useCounter ( {
54- initialValue : 5 ,
55- } )
56- ) ;
40+ const { result } = renderHook ( ( ) => useCounter ( 5 ) ) ;
5741
5842 act ( ( ) => {
5943 result . current . increment ( ) ;
@@ -71,8 +55,7 @@ describe('useCounter', () => {
7155
7256 it ( 'should not go below minimum value' , ( ) => {
7357 const { result } = renderHook ( ( ) =>
74- useCounter ( {
75- initialValue : 5 ,
58+ useCounter ( 5 , {
7659 min : 3 ,
7760 } )
7861 ) ;
@@ -88,8 +71,7 @@ describe('useCounter', () => {
8871
8972 it ( 'should not go above maximum value' , ( ) => {
9073 const { result } = renderHook ( ( ) =>
91- useCounter ( {
92- initialValue : 5 ,
74+ useCounter ( 5 , {
9375 max : 7 ,
9476 } )
9577 ) ;
@@ -105,8 +87,7 @@ describe('useCounter', () => {
10587
10688 it ( 'should use the provided step value for increment and decrement' , ( ) => {
10789 const { result } = renderHook ( ( ) =>
108- useCounter ( {
109- initialValue : 5 ,
90+ useCounter ( 5 , {
11091 step : 2 ,
11192 } )
11293 ) ;
@@ -126,17 +107,15 @@ describe('useCounter', () => {
126107
127108 it ( 'should adjust initial value to match constraints' , ( ) => {
128109 const { result } = renderHook ( ( ) =>
129- useCounter ( {
130- initialValue : 1 ,
110+ useCounter ( 1 , {
131111 min : 3 ,
132112 } )
133113 ) ;
134114
135115 expect ( result . current . count ) . toBe ( 3 ) ;
136116
137117 const { result : result2 } = renderHook ( ( ) =>
138- useCounter ( {
139- initialValue : 10 ,
118+ useCounter ( 10 , {
140119 max : 8 ,
141120 } )
142121 ) ;
@@ -146,7 +125,7 @@ describe('useCounter', () => {
146125
147126 it ( 'should allow setting arbitrary value within constraints' , ( ) => {
148127 const { result } = renderHook ( ( ) =>
149- useCounter ( {
128+ useCounter ( 0 , {
150129 min : 3 ,
151130 max : 8 ,
152131 } )
@@ -172,11 +151,7 @@ describe('useCounter', () => {
172151 } ) ;
173152
174153 it ( 'should work with updater function for setCount' , ( ) => {
175- const { result } = renderHook ( ( ) =>
176- useCounter ( {
177- initialValue : 5 ,
178- } )
179- ) ;
154+ const { result } = renderHook ( ( ) => useCounter ( 5 ) ) ;
180155
181156 act ( ( ) => {
182157 result . current . setCount ( prev => prev + 3 ) ;
0 commit comments