@samitouri / QOS-React / commits / 70de7e4a38

Test to verify findDOMNode does not throw in willMount

Adds a test to prevent a regression of throwing an error when calling `findDOMNode(this)` in a component's `componentWillMount` function. This previously used to throw an invariant violation but now does not any more.

Maher Beg committed Mar 20, 2016 at 18:31 UTC 70de7e4a38a2c49546666a41741f3cff5484fbc7
1 file changed +13
src/renderers/dom/client/__tests__/findDOMNode-test.js
+13
@@ -58,4 +58,17 @@ describe('findDOMNode', function() {
58 );
59 });
60
61 + it('findDOMNode should not throw an error when called within a component that is not mounted', function() {
62 + var Bar = React.createClass({
63 + componentWillMount: function() {
64 + expect(ReactDOM.findDOMNode(this)).toBeNull();
65 + },
66 + render: function() {
67 + return <div/>;
68 + },
69 + });
70 +
71 + expect(() => ReactTestUtils.renderIntoDocument(<Bar/>)).not.toThrow();
72 + });
73 +
74 });