mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fix ReactTestInstance::toJSON() with empty top-level components (#7523)
(cherry picked from commit 9f5b009f05)
This commit is contained in:
committed by
Paul O’Shannessy
parent
421bb8c53a
commit
f120c1b78e
@@ -127,6 +127,9 @@ ReactTestInstance.prototype.unmount = function(nextElement) {
|
||||
};
|
||||
ReactTestInstance.prototype.toJSON = function() {
|
||||
var inst = getHostComponentFromComposite(this._component);
|
||||
if (inst === null) {
|
||||
return null;
|
||||
}
|
||||
return inst.toJSON();
|
||||
};
|
||||
|
||||
|
||||
@@ -28,6 +28,14 @@ describe('ReactTestRenderer', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('renders a top-level empty component', function() {
|
||||
function Empty() {
|
||||
return null;
|
||||
}
|
||||
var renderer = ReactTestRenderer.create(<Empty />);
|
||||
expect(renderer.toJSON()).toEqual(null);
|
||||
});
|
||||
|
||||
it('exposes a type flag', function() {
|
||||
function Link() {
|
||||
return <a role="link" />;
|
||||
|
||||
Reference in New Issue
Block a user