Skip to content

Commit 3c6a75b

Browse files
committed
Add first (failing) test for useState.
1 parent 0ba8813 commit 3c6a75b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/spec.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import "jest-dom/extend-expect"
22
import React from "react"
33
import { render, fireEvent, cleanup, waitForElement } from "react-testing-library"
4-
import Async, { createInstance } from "./"
4+
import Async, { createInstance, useAsync } from "./"
55

66
afterEach(cleanup)
77

@@ -423,3 +423,10 @@ test("an unrelated change in props does not update the Context", async () => {
423423
)
424424
expect(one).toBe(two)
425425
})
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+
})

0 commit comments

Comments
 (0)