From 13c56c13d2746db96bf46ca7da020ddb34d3d785 Mon Sep 17 00:00:00 2001 From: Dan Seethaler Date: Wed, 13 Sep 2017 10:05:12 -0400 Subject: [PATCH] Revert "Remove undocumented TestUtils methods (#10681)" This reverts commit 18d6cb5ebe56e96c293e82e0c861ed9f19765671. --- src/renderers/dom/test/ReactTestUtilsEntry.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/renderers/dom/test/ReactTestUtilsEntry.js b/src/renderers/dom/test/ReactTestUtilsEntry.js index 1709972f4176d..f809e8bb27465 100644 --- a/src/renderers/dom/test/ReactTestUtilsEntry.js +++ b/src/renderers/dom/test/ReactTestUtilsEntry.js @@ -178,6 +178,38 @@ var ReactTestUtils = { return constructor === type; }, + // TODO: deprecate? It's undocumented and unused. + isCompositeComponentElement: function(inst) { + if (!React.isValidElement(inst)) { + return false; + } + // We check the prototype of the type that will get mounted, not the + // instance itself. This is a future proof way of duck typing. + var prototype = inst.type.prototype; + return ( + typeof prototype.render === 'function' && + typeof prototype.setState === 'function' + ); + }, + + // TODO: deprecate? It's undocumented and unused. + isCompositeComponentElementWithType: function(inst, type) { + var internalInstance = ReactInstanceMap.get(inst); + var constructor = internalInstance._currentElement.type; + + return !!(ReactTestUtils.isCompositeComponentElement(inst) && + constructor === type); + }, + + // TODO: deprecate? It's undocumented and unused. + getRenderedChildOfCompositeComponent: function(inst) { + if (!ReactTestUtils.isCompositeComponent(inst)) { + return null; + } + var internalInstance = ReactInstanceMap.get(inst); + return internalInstance._renderedComponent.getPublicInstance(); + }, + findAllInRenderedTree: function(inst, test) { if (!inst) { return [];