mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Deprecate test utils mock component follow up (#13194)
* De-duplicate the mockComponent deprecation warning * Added fb.me link to mockComponent
This commit is contained in:
+5
-1
@@ -57,9 +57,13 @@ describe('ReactTestUtils', () => {
|
||||
ReactTestUtils.mockComponent(MockedComponent),
|
||||
).toLowPriorityWarnDev(
|
||||
'ReactTestUtils.mockComponent() is deprecated. ' +
|
||||
'Use shallow rendering or jest.mock() instead.',
|
||||
'Use shallow rendering or jest.mock() instead.\n\n' +
|
||||
'See https://fb.me/test-utils-mock-component for more information.',
|
||||
);
|
||||
|
||||
// De-duplication check
|
||||
ReactTestUtils.mockComponent(MockedComponent);
|
||||
|
||||
const container = document.createElement('div');
|
||||
ReactDOM.render(<MockedComponent>Hello</MockedComponent>, container);
|
||||
expect(container.textContent).toBe('Hello');
|
||||
|
||||
+11
-5
@@ -33,6 +33,8 @@ const {
|
||||
|
||||
function Event(suffix) {}
|
||||
|
||||
let hasWarnedAboutDeprecatedMockComponent = false;
|
||||
|
||||
/**
|
||||
* @class ReactTestUtils
|
||||
*/
|
||||
@@ -310,11 +312,15 @@ const ReactTestUtils = {
|
||||
* @return {object} the ReactTestUtils object (for chaining)
|
||||
*/
|
||||
mockComponent: function(module, mockTagName) {
|
||||
lowPriorityWarning(
|
||||
false,
|
||||
'ReactTestUtils.mockComponent() is deprecated. ' +
|
||||
'Use shallow rendering or jest.mock() instead.',
|
||||
);
|
||||
if (!hasWarnedAboutDeprecatedMockComponent) {
|
||||
hasWarnedAboutDeprecatedMockComponent = true;
|
||||
lowPriorityWarning(
|
||||
false,
|
||||
'ReactTestUtils.mockComponent() is deprecated. ' +
|
||||
'Use shallow rendering or jest.mock() instead.\n\n' +
|
||||
'See https://fb.me/test-utils-mock-component for more information.',
|
||||
);
|
||||
}
|
||||
|
||||
mockTagName = mockTagName || module.mockTagName || 'div';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user