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.  * @jest-environment node
    
  8.  */
    
  9. 
    
  10. 'use strict';
    
  11. 
    
  12. describe('ReactIncrementalErrorReplay-test', () => {
    
  13.   const React = require('react');
    
  14.   const ReactTestRenderer = require('react-test-renderer');
    
  15. 
    
  16.   it('copies all keys when stashing potentially failing work', () => {
    
  17.     // Note: this test is fragile and relies on internals.
    
  18.     // We almost always try to avoid such tests, but here the cost of
    
  19.     // the list getting out of sync (and causing subtle bugs in rare cases)
    
  20.     // is higher than the cost of maintaining the test.
    
  21. 
    
  22.     // This is the method we're going to test.
    
  23.     // If this is no longer used, you can delete this test file.;
    
  24.     const {assignFiberPropertiesInDEV} = require('../ReactFiber');
    
  25. 
    
  26.     // Get a real fiber.
    
  27.     const realFiber = ReactTestRenderer.create(<div />).root._currentFiber();
    
  28.     const stash = assignFiberPropertiesInDEV(null, realFiber);
    
  29. 
    
  30.     // Verify we get all the same fields.
    
  31.     expect(realFiber).toEqual(stash);
    
  32. 
    
  33.     // Mutate the original.
    
  34.     for (const key in realFiber) {
    
  35.       realFiber[key] = key + '_' + Math.random();
    
  36.     }
    
  37.     expect(realFiber).not.toEqual(stash);
    
  38. 
    
  39.     // Verify we can still "revert" to the stashed properties.
    
  40.     expect(assignFiberPropertiesInDEV(realFiber, stash)).toBe(realFiber);
    
  41.     expect(realFiber).toEqual(stash);
    
  42.   });
    
  43. });