@samitouri / QOS-React-2 / commits / 70985ba68d

Squash getDOMNode warning from isDOMComponent

Fixes #3329.

Ben Alpert committed Mar 13, 2015 at 17:11 UTC 70985ba68dac9b3d01b1d59a86466a1c23e8180b
2 files changed +28 -1
src/test/ReactTestUtils.js
+1 -1
@@ -66,7 +66,7 @@ var ReactTestUtils = {
66 isDOMComponent: function(inst) {
67 // TODO: Fix this heuristic. It's just here because composites can currently
68 // pretend to be DOM components.
69 - return !!(inst && inst.getDOMNode && inst.tagName);
69 + return !!(inst && inst.tagName && inst.getDOMNode);
70 },
71
72 isDOMComponentElement: function(inst) {
src/test/__tests__/ReactTestUtils-test.js
+27
@@ -179,4 +179,31 @@ describe('ReactTestUtils', function() {
179 // Should be document order, not mount order (which would be purple, orange)
180 expect(log).toEqual(['orangepurple', 'orange', 'purple']);
181 });
182 +
183 + it('does not warn for getDOMNode on ES6 classes', function() {
184 + var Foo = React.createClass({
185 + render: function() {
186 + return <div />;
187 + }
188 + });
189 +
190 + class Bar extends React.Component {
191 + render() {
192 + return <div />;
193 + }
194 + }
195 +
196 + spyOn(console, 'warn');
197 +
198 + var foo = ReactTestUtils.renderIntoDocument(<Foo />);
199 + expect(ReactTestUtils.isDOMComponent(foo)).toBe(false);
200 +
201 + var bar = ReactTestUtils.renderIntoDocument(<Bar />);
202 + expect(ReactTestUtils.isDOMComponent(bar)).toBe(false);
203 +
204 + var div = ReactTestUtils.renderIntoDocument(<div />);
205 + expect(ReactTestUtils.isDOMComponent(div)).toBe(true);
206 +
207 + expect(console.warn.calls.length).toBe(0);
208 + });
209 });