Skip to content

Commit e244c7c

Browse files
committed
Revert "Remove undocumented TestUtils methods (facebook#10681)"
This reverts commit 18d6cb5.
1 parent 65b9ad9 commit e244c7c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/renderers/dom/test/ReactTestUtilsEntry.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,38 @@ var ReactTestUtils = {
178178
return constructor === type;
179179
},
180180

181+
// TODO: deprecate? It's undocumented and unused.
182+
isCompositeComponentElement: function(inst) {
183+
if (!React.isValidElement(inst)) {
184+
return false;
185+
}
186+
// We check the prototype of the type that will get mounted, not the
187+
// instance itself. This is a future proof way of duck typing.
188+
var prototype = inst.type.prototype;
189+
return (
190+
typeof prototype.render === 'function' &&
191+
typeof prototype.setState === 'function'
192+
);
193+
},
194+
195+
// TODO: deprecate? It's undocumented and unused.
196+
isCompositeComponentElementWithType: function(inst, type) {
197+
var internalInstance = ReactInstanceMap.get(inst);
198+
var constructor = internalInstance._currentElement.type;
199+
200+
return !!(ReactTestUtils.isCompositeComponentElement(inst) &&
201+
constructor === type);
202+
},
203+
204+
// TODO: deprecate? It's undocumented and unused.
205+
getRenderedChildOfCompositeComponent: function(inst) {
206+
if (!ReactTestUtils.isCompositeComponent(inst)) {
207+
return null;
208+
}
209+
var internalInstance = ReactInstanceMap.get(inst);
210+
return internalInstance._renderedComponent.getPublicInstance();
211+
},
212+
181213
findAllInRenderedTree: function(inst, test) {
182214
if (!inst) {
183215
return [];

0 commit comments

Comments
 (0)