mirror of
https://github.com/facebook/react.git
synced 2026-02-25 13:13:03 +00:00
Merge pull request #3412 from spicyj/gh-3329
Squash getDOMNode warning from isDOMComponent
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user