tests: add regression test for reading ReactCurrentOwner stateNode (#12412)

* tests: add regression test for reading ReactCurrentOwner stateNode

* tests: replace expect with just rendering the component
This commit is contained in:
Rauno Freiberg
2018-04-16 15:44:17 +01:00
committed by Dan Abramov
parent 1591c8ebab
commit a4cef29703
+20
View File
@@ -377,6 +377,26 @@ describe('ReactDOM', () => {
}
});
it('should not crash calling findDOMNode inside a functional component', () => {
const container = document.createElement('div');
class Component extends React.Component {
render() {
return <div />;
}
}
const instance = ReactTestUtils.renderIntoDocument(<Component />);
const App = () => {
ReactDOM.findDOMNode(instance);
return <div />;
};
if (__DEV__) {
ReactDOM.render(<App />, container);
}
});
it('throws in DEV if jsdom is destroyed by the time setState() is called', () => {
class App extends React.Component {
state = {x: 1};