Merge pull request #3412 from spicyj/gh-3329

Squash getDOMNode warning from isDOMComponent
This commit is contained in:
Ben Alpert
2015-03-13 17:55:02 -07:00
2 changed files with 28 additions and 1 deletions

View File

@@ -66,7 +66,7 @@ var ReactTestUtils = {
isDOMComponent: function(inst) {
// TODO: Fix this heuristic. It's just here because composites can currently
// pretend to be DOM components.
return !!(inst && inst.getDOMNode && inst.tagName);
return !!(inst && inst.tagName && inst.getDOMNode);
},
isDOMComponentElement: function(inst) {

View File

@@ -179,4 +179,31 @@ describe('ReactTestUtils', function() {
// Should be document order, not mount order (which would be purple, orange)
expect(log).toEqual(['orangepurple', 'orange', 'purple']);
});
it('does not warn for getDOMNode on ES6 classes', function() {
var Foo = React.createClass({
render: function() {
return <div />;
}
});
class Bar extends React.Component {
render() {
return <div />;
}
}
spyOn(console, 'warn');
var foo = ReactTestUtils.renderIntoDocument(<Foo />);
expect(ReactTestUtils.isDOMComponent(foo)).toBe(false);
var bar = ReactTestUtils.renderIntoDocument(<Bar />);
expect(ReactTestUtils.isDOMComponent(bar)).toBe(false);
var div = ReactTestUtils.renderIntoDocument(<div />);
expect(ReactTestUtils.isDOMComponent(div)).toBe(true);
expect(console.warn.calls.length).toBe(0);
});
});