-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
@testing-library+react-12+12.1.5.patch
63 lines (59 loc) · 1.73 KB
/
@testing-library+react-12+12.1.5.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
diff --git a/node_modules/@testing-library/react-12/dist/pure.js b/node_modules/@testing-library/react-12/dist/pure.js
index 72287ac..f0d2c59 100644
--- a/node_modules/@testing-library/react-12/dist/pure.js
+++ b/node_modules/@testing-library/react-12/dist/pure.js
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
});
var _exportNames = {
render: true,
+ renderHook: true,
cleanup: true,
act: true,
fireEvent: true
@@ -25,6 +26,7 @@ Object.defineProperty(exports, "fireEvent", {
}
});
exports.render = render;
+exports.renderHook = renderHook;
var React = _interopRequireWildcard(require("react"));
@@ -138,6 +140,42 @@ function cleanup() {
} // maybe one day we'll expose this (perhaps even as a utility returned by render).
// but let's wait until someone asks for it.
+function renderHook(renderCallback, options = {}) {
+ const {
+ initialProps,
+ ...renderOptions
+ } = options;
+ const result = /*#__PURE__*/React.createRef();
+
+ function TestComponent({
+ renderCallbackProps
+ }) {
+ const pendingResult = renderCallback(renderCallbackProps);
+ React.useEffect(() => {
+ result.current = pendingResult;
+ });
+ return null;
+ }
+
+ const {
+ rerender: baseRerender,
+ unmount
+ } = render( /*#__PURE__*/React.createElement(TestComponent, {
+ renderCallbackProps: initialProps
+ }), renderOptions);
+
+ function rerender(rerenderCallbackProps) {
+ return baseRerender( /*#__PURE__*/React.createElement(TestComponent, {
+ renderCallbackProps: rerenderCallbackProps
+ }));
+ }
+
+ return {
+ result,
+ rerender,
+ unmount
+ };
+} // just re-export everything from dom-testing-library
function cleanupAtContainer(container) {
(0, _actCompat.default)(() => {