Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/renderers/testing/ReactTestRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@ ReactTestComponent.prototype.toJSON = function() {
childrenJSON.push(json);
}
}
return {
var object = {
type: this._currentElement.type,
props: props,
children: childrenJSON.length ? childrenJSON : null,
};
Object.defineProperty(object, '$$typeof', {
value: Symbol.for('react.test.json'),
});
return object;
};
Object.assign(ReactTestComponent.prototype, ReactMultiChild.Mixin);

Expand Down
16 changes: 16 additions & 0 deletions src/renderers/testing/__tests__/ReactTestRenderer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ describe('ReactTestRenderer', function() {
});
});

it('exposes a type flag', function() {
function Link() {
return <a role="link" />;
}
var renderer = ReactTestRenderer.create(<Link />);
var object = renderer.toJSON();
expect(object.$$typeof).toBe(Symbol.for('react.test.json'));

// $$typeof should not be enumerable.
for (var key in object) {
if (Object.prototype.hasOwnProperty.call(object, key)) {
expect(key).not.toBe('$$typeof');
}
}
});

it('renders some basics with an update', function() {
var renders = 0;
var Component = React.createClass({
Expand Down