File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1
1
import "jest-dom/extend-expect"
2
2
import React from "react"
3
3
import { render , fireEvent , cleanup , waitForElement } from "react-testing-library"
4
- import Async , { createInstance } from "./"
4
+ import Async , { createInstance , useAsync } from "./"
5
5
6
6
afterEach ( cleanup )
7
7
@@ -423,3 +423,10 @@ test("an unrelated change in props does not update the Context", async () => {
423
423
)
424
424
expect ( one ) . toBe ( two )
425
425
} )
426
+
427
+ test ( "useAsync returns render props" , async ( ) => {
428
+ const promiseFn = ( ) => new Promise ( resolve => setTimeout ( resolve , 0 , "done" ) )
429
+ const Async = ( { children, ...props } ) => children ( useAsync ( props ) )
430
+ const { getByText } = render ( < Async promiseFn = { promiseFn } > { ( { data } ) => data || null } </ Async > )
431
+ await waitForElement ( ( ) => getByText ( "done" ) )
432
+ } )
You can’t perform that action at this time.
0 commit comments