Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove functions marked as undocumented and unused #10096

Closed
Closed
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
3 changes: 3 additions & 0 deletions scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,9 @@ src/renderers/dom/test/__tests__/ReactTestUtils-test.js
* should enable rendering of cloned element
* should set the type of the event
* should work with renderIntoDocument
* should log a deprecation warning if ReactTestUtils.isCompositeComponentElement is invoked
* should log a deprecation warning if ReactTestUtils.isCompositeComponentElementWithType is invoked
* should log a deprecation warning if ReactTestUtils.getRenderedChildOfCompositeComponent is invoked

src/renderers/native/__tests__/ReactNativeAttributePayload-test.js
* should work with simple example
Expand Down
19 changes: 16 additions & 3 deletions src/renderers/dom/test/ReactTestUtilsEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var ReactInstanceMap = require('ReactInstanceMap');
var ReactShallowRenderer = require('ReactShallowRendererEntry'); // TODO (bvaughn) Remove this import before 16.0.0
var ReactTypeOfWork = require('ReactTypeOfWork');
var SyntheticEvent = require('SyntheticEvent');
var lowPriorityWarning = require('lowPriorityWarning');

var invariant = require('fbjs/lib/invariant');
var warning = require('fbjs/lib/warning');
Expand Down Expand Up @@ -194,7 +195,6 @@ var ReactTestUtils = {
return constructor === type;
},

// TODO: deprecate? It's undocumented and unused.
isCompositeComponentElement: function(inst) {
if (!React.isValidElement(inst)) {
return false;
Expand All @@ -208,7 +208,6 @@ var ReactTestUtils = {
);
},

// TODO: deprecate? It's undocumented and unused.
isCompositeComponentElementWithType: function(inst, type) {
var internalInstance = ReactInstanceMap.get(inst);
var constructor = internalInstance._currentElement.type;
Expand All @@ -217,7 +216,6 @@ var ReactTestUtils = {
constructor === type);
},

// TODO: deprecate? It's undocumented and unused.
getRenderedChildOfCompositeComponent: function(inst) {
if (!ReactTestUtils.isCompositeComponent(inst)) {
return null;
Expand Down Expand Up @@ -570,4 +568,19 @@ Object.keys(topLevelTypes).forEach(function(eventType) {
);
});

[
'isCompositeComponentElement',
'isCompositeComponentElementWithType',
'getRenderedChildOfCompositeComponent',
].forEach(fnName => {
var fn = ReactTestUtils[fnName];
ReactTestUtils[fnName] = function(...args) {
lowPriorityWarning(
false,
`ReactTestUtils.${fnName} is deprecated as of React v15.6.2.`,
);
return fn(...args);
};
});

module.exports = ReactTestUtils;
21 changes: 21 additions & 0 deletions src/renderers/dom/test/__tests__/ReactTestUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,5 +843,26 @@ describe('ReactTestUtils', () => {
jasmine.objectContaining({target: input}),
);
});

[
'isCompositeComponentElement',
'isCompositeComponentElementWithType',
'getRenderedChildOfCompositeComponent',
].forEach(fnName => {
it(
`should log a deprecation warning if ReactTestUtils.${fnName} is invoked`,
() => {
spyOn(console, 'warn');

try {
ReactTestUtils[fnName]();
} catch (_) {}

expect(console.warn.calls.argsFor(0)[0]).toBe(
`Warning: ReactTestUtils.${fnName} is deprecated as of React v15.6.2.`,
);
},
);
});
});
});