1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  *
    
  7.  * @emails react-core
    
  8.  */
    
  9. 
    
  10. 'use strict';
    
  11. 
    
  12. let React;
    
  13. let ReactDOM;
    
  14. 
    
  15. let MockedComponent;
    
  16. let ReactDOMServer;
    
  17. 
    
  18. describe('ReactMockedComponent', () => {
    
  19.   beforeEach(() => {
    
  20.     React = require('react');
    
  21.     ReactDOM = require('react-dom');
    
  22.     ReactDOMServer = require('react-dom/server');
    
  23. 
    
  24.     MockedComponent = class extends React.Component {
    
  25.       render() {
    
  26.         throw new Error('Should not get here.');
    
  27.       }
    
  28.     };
    
  29.     // This is close enough to what a Jest mock would give us.
    
  30.     MockedComponent.prototype.render = jest.fn();
    
  31.   });
    
  32. 
    
  33.   it('should allow a mocked component to be rendered', () => {
    
  34.     const container = document.createElement('container');
    
  35.     ReactDOM.render(<MockedComponent />, container);
    
  36.   });
    
  37. 
    
  38.   it('should allow a mocked component to be updated in dev', () => {
    
  39.     const container = document.createElement('container');
    
  40.     ReactDOM.render(<MockedComponent />, container);
    
  41.     ReactDOM.render(<MockedComponent />, container);
    
  42.   });
    
  43. 
    
  44.   it('should allow a mocked component to be rendered in dev (SSR)', () => {
    
  45.     ReactDOMServer.renderToString(<MockedComponent />);
    
  46.   });
    
  47. });