@@ -64,40 +64,31 @@ targets.forEach((target) => {
6464 describe ( `${ target } ` , ( ) => {
6565 it ( 'Should use auto scroll' , ( ) => {
6666 const { result } = renderHook ( ( ) => {
67- if ( target )
68- return useAutoScroll ( target ) as unknown as {
69- ref : StateRef < HTMLElement > ;
70- } ;
67+ if ( target ) return useAutoScroll ( target ) as unknown as StateRef < HTMLElement > ;
7168 return useAutoScroll < HTMLElement > ( ) ;
7269 } ) ;
7370
74- if ( ! target ) expect ( result . current . ref ) . toBeTypeOf ( 'function' ) ;
71+ if ( ! target ) expect ( result . current ) . toBeTypeOf ( 'function' ) ;
7572 if ( target ) expect ( result . current ) . toBeUndefined ( ) ;
7673 } ) ;
7774
7875 it ( 'Should use auto scroll on server side' , ( ) => {
7976 const { result } = renderHookServer ( ( ) => {
80- if ( target )
81- return useAutoScroll ( target ) as unknown as {
82- ref : StateRef < HTMLElement > ;
83- } ;
77+ if ( target ) return useAutoScroll ( target ) as unknown as StateRef < HTMLElement > ;
8478 return useAutoScroll < HTMLElement > ( ) ;
8579 } ) ;
8680
87- if ( ! target ) expect ( result . current . ref ) . toBeTypeOf ( 'function' ) ;
81+ if ( ! target ) expect ( result . current ) . toBeTypeOf ( 'function' ) ;
8882 if ( target ) expect ( result . current ) . toBeUndefined ( ) ;
8983 } ) ;
9084
9185 it ( 'Should auto scroll when content changes' , ( ) => {
9286 const { result } = renderHook ( ( ) => {
93- if ( target )
94- return useAutoScroll ( target ) as unknown as {
95- ref : StateRef < HTMLElement > ;
96- } ;
87+ if ( target ) return useAutoScroll ( target ) as unknown as StateRef < HTMLElement > ;
9788 return useAutoScroll < HTMLElement > ( ) ;
9889 } ) ;
9990
100- if ( ! target ) act ( ( ) => result . current . ref ( element ) ) ;
91+ if ( ! target ) act ( ( ) => result . current ( element ) ) ;
10192
10293 act ( ( ) => trigger . callback ( element ) ) ;
10394
@@ -109,11 +100,11 @@ targets.forEach((target) => {
109100 if ( target )
110101 return useAutoScroll ( target , {
111102 enabled : false
112- } ) as unknown as { ref : StateRef < HTMLElement > } ;
103+ } ) as unknown as StateRef < HTMLElement > ;
113104 return useAutoScroll < HTMLElement > ( { enabled : false } ) ;
114105 } ) ;
115106
116- if ( ! target ) act ( ( ) => result . current . ref ( element ) ) ;
107+ if ( ! target ) act ( ( ) => result . current ( element ) ) ;
117108
118109 act ( ( ) => trigger . callback ( element ) ) ;
119110
@@ -125,11 +116,11 @@ targets.forEach((target) => {
125116 if ( target )
126117 return useAutoScroll ( target , {
127118 force : true
128- } ) as unknown as { ref : StateRef < HTMLElement > } ;
119+ } ) as unknown as StateRef < HTMLElement > ;
129120 return useAutoScroll < HTMLElement > ( { force : true } ) ;
130121 } ) ;
131122
132- if ( ! target ) act ( ( ) => result . current . ref ( element ) ) ;
123+ if ( ! target ) act ( ( ) => result . current ( element ) ) ;
133124
134125 act ( ( ) => {
135126 Object . defineProperty ( element , 'scrollTop' , { value : 200 } ) ;
@@ -143,14 +134,11 @@ targets.forEach((target) => {
143134
144135 it ( 'Should handle auto scroll on manual scroll up' , ( ) => {
145136 const { result } = renderHook ( ( ) => {
146- if ( target )
147- return useAutoScroll ( target ) as unknown as {
148- ref : StateRef < HTMLElement > ;
149- } ;
137+ if ( target ) return useAutoScroll ( target ) as unknown as StateRef < HTMLElement > ;
150138 return useAutoScroll < HTMLElement > ( ) ;
151139 } ) ;
152140
153- if ( ! target ) act ( ( ) => result . current . ref ( element ) ) ;
141+ if ( ! target ) act ( ( ) => result . current ( element ) ) ;
154142
155143 act ( ( ) => {
156144 Object . defineProperty ( element , 'scrollTop' , { value : 200 } ) ;
@@ -173,14 +161,11 @@ targets.forEach((target) => {
173161
174162 it ( 'Should handle touch events' , ( ) => {
175163 const { result } = renderHook ( ( ) => {
176- if ( target )
177- return useAutoScroll ( target ) as unknown as {
178- ref : StateRef < HTMLElement > ;
179- } ;
164+ if ( target ) return useAutoScroll ( target ) as unknown as StateRef < HTMLElement > ;
180165 return useAutoScroll < HTMLElement > ( ) ;
181166 } ) ;
182167
183- if ( ! target ) act ( ( ) => result . current . ref ( element ) ) ;
168+ if ( ! target ) act ( ( ) => result . current ( element ) ) ;
184169
185170 act ( ( ) => {
186171 element . dispatchEvent (
@@ -223,14 +208,11 @@ targets.forEach((target) => {
223208 const removeEventListenerSpy = vi . spyOn ( element , 'removeEventListener' ) ;
224209
225210 const { result, unmount } = renderHook ( ( ) => {
226- if ( target )
227- return useAutoScroll ( target ) as unknown as {
228- ref : StateRef < HTMLElement > ;
229- } ;
211+ if ( target ) return useAutoScroll ( target ) as unknown as StateRef < HTMLElement > ;
230212 return useAutoScroll < HTMLElement > ( ) ;
231213 } ) ;
232214
233- if ( ! target ) act ( ( ) => result . current . ref ( element ) ) ;
215+ if ( ! target ) act ( ( ) => result . current ( element ) ) ;
234216
235217 unmount ( ) ;
236218
@@ -243,16 +225,13 @@ targets.forEach((target) => {
243225 it ( 'Should handle target changes' , ( ) => {
244226 const { result, rerender } = renderHook (
245227 ( target ) => {
246- if ( target )
247- return useAutoScroll ( target ) as unknown as {
248- ref : StateRef < HTMLElement > ;
249- } ;
228+ if ( target ) return useAutoScroll ( target ) as unknown as StateRef < HTMLElement > ;
250229 return useAutoScroll < HTMLElement > ( ) ;
251230 } ,
252231 { initialProps : target }
253232 ) ;
254233
255- if ( ! target ) act ( ( ) => result . current . ref ( element ) ) ;
234+ if ( ! target ) act ( ( ) => result . current ( element ) ) ;
256235
257236 expect ( mockMutationObserverObserve ) . toHaveBeenCalledTimes ( 1 ) ;
258237
0 commit comments