-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
34 lines (30 loc) · 864 Bytes
/
test.js
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
import React, { useEffect } from "react";
import * as ReactDOM from "react-dom";
import * as ReactDOMTestUtils from "react-dom/test-utils";
function Component() {
useEffect(() => () => {}, []); // make sure to return a cleanup
return <>x</>;
}
let baseElement = null;
let container = null;
beforeEach(() => {
baseElement = document.body;
container = baseElement.appendChild(document.createElement("div"));
});
afterEach(() => {
ReactDOMTestUtils.act(() => {
ReactDOM.unmountComponentAtNode(container);
});
baseElement.removeChild(container);
container = null;
});
it("it", function () {
ReactDOMTestUtils.act(() => {
ReactDOM.render(<Component />, container);
});
return Promise.resolve().then(() => {
return ReactDOMTestUtils.act(() => {
return Promise.resolve();
}).then(() => {});
});
}, 1); // force a timeout