@@ -26,4 +26,34 @@ describe('useMultiRef', () => {
2626 expect ( ref2 ) . toHaveBeenCalledWith ( null ) ;
2727 expect ( ref3 ) . toHaveBeenCalledWith ( null ) ;
2828 } ) ;
29+
30+ it ( 'should work with non-function refs' , ( ) => {
31+ const ref1 = { current : null } ;
32+ const ref2 = { current : null } ;
33+ const ref3 = { current : null } ;
34+ const { result } = renderHook ( ( ) =>
35+ useMultiRef < HTMLDivElement | null > ( ref1 , ref2 , ref3 )
36+ ) ;
37+ const multiRef = result . current ;
38+ const element = document . createElement ( 'div' ) ;
39+ multiRef ( element ) ;
40+ expect ( ref1 . current ) . toBe ( element ) ;
41+ expect ( ref2 . current ) . toBe ( element ) ;
42+ expect ( ref3 . current ) . toBe ( element ) ;
43+ } ) ;
44+
45+ it ( 'should handle a mix of function and non-function refs' , ( ) => {
46+ const ref1 = jest . fn ( ) ;
47+ const ref2 = { current : null } ;
48+ const ref3 = jest . fn ( ) ;
49+ const { result } = renderHook ( ( ) =>
50+ useMultiRef < HTMLDivElement | null > ( ref1 , ref2 , ref3 )
51+ ) ;
52+ const multiRef = result . current ;
53+ const element = document . createElement ( 'div' ) ;
54+ multiRef ( element ) ;
55+ expect ( ref1 ) . toHaveBeenCalledWith ( element ) ;
56+ expect ( ref2 . current ) . toBe ( element ) ;
57+ expect ( ref3 ) . toHaveBeenCalledWith ( element ) ;
58+ } ) ;
2959} ) ;
0 commit comments