@@ -43,7 +43,7 @@ describe('useSelfAdjustingInterval', () => {
4343 } )
4444
4545 test ( 'calls callback immediately and sets up next interval' , async ( ) => {
46- const callback = vi . fn ( ) . mockResolvedValue ( { retryIntervalMs : 1000 } )
46+ const callback = vi . fn ( ( ) => Promise . resolve ( { retryIntervalMs : 1000 } ) )
4747
4848 renderHook ( ( ) => useSelfAdjustingInterval ( callback ) )
4949
@@ -59,9 +59,9 @@ describe('useSelfAdjustingInterval', () => {
5959 test ( 'adjusts interval based on callback return value' , async ( ) => {
6060 const callback = vi
6161 . fn ( )
62- . mockResolvedValueOnce ( { retryIntervalMs : 1000 } )
63- . mockResolvedValueOnce ( { retryIntervalMs : 2000 } )
64- . mockResolvedValueOnce ( { retryIntervalMs : null } )
62+ . mockImplementationOnce ( ( ) => Promise . resolve ( { retryIntervalMs : 1000 } ) )
63+ . mockImplementationOnce ( ( ) => Promise . resolve ( { retryIntervalMs : 2000 } ) )
64+ . mockImplementationOnce ( ( ) => Promise . resolve ( { retryIntervalMs : null } ) )
6565 renderHook ( ( ) => useSelfAdjustingInterval ( callback ) )
6666
6767 // Initial call
@@ -82,7 +82,7 @@ describe('useSelfAdjustingInterval', () => {
8282 } )
8383
8484 test ( 'deals with the callback throwing an error' , async ( ) => {
85- const callback = vi . fn ( ) . mockRejectedValue ( new Error ( 'test error' ) )
85+ const callback = vi . fn ( ( ) => Promise . reject ( new Error ( 'test error' ) ) )
8686 const { lastResult} = renderHook ( ( ) => useSelfAdjustingInterval ( callback ) )
8787
8888 await vi . advanceTimersByTimeAsync ( 0 )
@@ -91,7 +91,7 @@ describe('useSelfAdjustingInterval', () => {
9191 } )
9292
9393 test ( 'cleans up timeout on unmount' , async ( ) => {
94- const callback = vi . fn ( ) . mockResolvedValue ( { retryIntervalMs : 1000 } )
94+ const callback = vi . fn ( ( ) => Promise . resolve ( { retryIntervalMs : 1000 } ) )
9595
9696 const { unmount} = renderHook ( ( ) => useSelfAdjustingInterval ( callback ) )
9797
0 commit comments