@@ -92,7 +92,8 @@ it('stops loading on failure and returns the error', async () => {
9292
9393 await waitForNextUpdate ( ) ;
9494
95- expect ( result . current . error ) . toBe ( thrownError ) ;
95+ expect ( result . current . error ?. value ) . toBe ( thrownError ) ;
96+ expect ( result . current . error ?. retry ) . not . toBeUndefined ( ) ;
9697 expect ( result . current . isLoading ) . toEqual ( false ) ;
9798} ) ;
9899
@@ -119,7 +120,8 @@ it('can set error', async () => {
119120 result . current . setError ( thrownError ) ;
120121 } ) ;
121122
122- expect ( result . current . error ) . toEqual ( thrownError ) ;
123+ expect ( result . current . error ?. value ) . toEqual ( thrownError ) ;
124+ expect ( result . current . error ?. retry ) . not . toBeUndefined ( ) ;
123125} ) ;
124126
125127it ( 'can set isLoading' , async ( ) => {
@@ -138,6 +140,7 @@ it('can set isLoading', async () => {
138140
139141describe ( 'retry' , ( ) => {
140142 it ( 'sets loading true' , async ( ) => {
143+ callbackFn . mockRejectedValue ( thrownError ) ;
141144 const { result, waitForNextUpdate } = renderHook ( useHookHelper , {
142145 initialProps,
143146 } ) ;
@@ -146,7 +149,7 @@ describe('retry', () => {
146149 expect ( result . current . isLoading ) . toBe ( false ) ;
147150
148151 act ( ( ) => {
149- result . current . retry ( ) ;
152+ result . current . error ! . retry ( ) ;
150153 } ) ;
151154
152155 expect ( result . current . isLoading ) . toBe ( true ) ;
@@ -162,9 +165,9 @@ describe('retry', () => {
162165 } ) ;
163166
164167 await waitForNextUpdate ( ) ;
165- expect ( result . current . error ) . toBe ( thrownError ) ;
168+ expect ( result . current . error ?. value ) . toBe ( thrownError ) ;
166169
167- await act ( result . current . retry ) ;
170+ await act ( result . current . error ! . retry ) ;
168171
169172 expect ( result . current . error ) . toBeUndefined ( ) ;
170173 } ) ;
@@ -179,19 +182,22 @@ describe('retry', () => {
179182 } ) ;
180183
181184 await waitForNextUpdate ( ) ;
182- expect ( result . current . error ) . toBe ( thrownError ) ;
185+ expect ( result . current . error ?. value ) . toBe ( thrownError ) ;
183186 expect ( result . current . data ) . toBeUndefined ( ) ;
184187
185- await act ( result . current . retry ) ;
188+ await act ( result . current . error ! . retry ) ;
186189
187190 expect ( result . current . data ) . toBe ( val ) ;
191+ expect ( result . current . error ) . toBeUndefined ( ) ;
188192 } ) ;
189193} ) ;
190194
191195/// These tests won't fail their execution, but the type-checking instead.
192196describe ( 'test types' , ( ) => {
193197 type Assert < T , Expected > = T extends Expected
194- ? ( Expected extends T ? true : never )
198+ ? Expected extends T
199+ ? true
200+ : never
195201 : never ;
196202
197203 describe ( '`initialValue` is unset' , ( ) => {
0 commit comments