Skip to content

Commit cb77db9

Browse files
committed
updated to RTL v5.9 to use built in wrapper option
1 parent 7861260 commit cb77db9

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

package-lock.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"contributors:add": "all-contributors add"
1818
},
1919
"dependencies": {
20-
"react-testing-library": "^5.8.0"
20+
"react-testing-library": "^5.9.0"
2121
},
2222
"devDependencies": {
2323
"@babel/cli": "^7.2.3",
@@ -29,7 +29,7 @@
2929
"all-contributors-cli": "^6.1.1",
3030
"babel-eslint": "^10.0.1",
3131
"babel-plugin-module-resolver": "^3.2.0",
32-
"eslint": "^5.14.0",
32+
"eslint": "^5.14.1",
3333
"eslint-config-prettier": "^4.0.0",
3434
"eslint-plugin-prettier": "^3.0.1",
3535
"husky": "^1.3.1",

src/index.js

+11-15
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,19 @@ function TestHook({ callback, hookProps, children }) {
66
return null
77
}
88

9-
function renderHook(callback, options = {}) {
9+
function renderHook(callback, { initialProps, ...options } = {}) {
1010
const result = { current: null }
11-
const hookProps = { current: options.initialProps }
12-
13-
const toRender = () => {
14-
const hookRender = (
15-
<TestHook callback={callback} hookProps={hookProps.current}>
16-
{(res) => {
17-
result.current = res
18-
}}
19-
</TestHook>
20-
)
21-
22-
return options.wrapper ? React.createElement(options.wrapper, null, hookRender) : hookRender
23-
}
11+
const hookProps = { current: initialProps }
12+
13+
const toRender = () => (
14+
<TestHook callback={callback} hookProps={hookProps.current}>
15+
{(res) => {
16+
result.current = res
17+
}}
18+
</TestHook>
19+
)
2420

25-
const { unmount, rerender: rerenderComponent } = render(toRender())
21+
const { unmount, rerender: rerenderComponent } = render(toRender(), options)
2622

2723
return {
2824
result,

0 commit comments

Comments
 (0)