/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core * @jest-environment node */ 'use strict'; let React; let ReactNoop; let Scheduler; let PropTypes; let assertConsoleErrorDev; let waitForAll; let waitFor; let waitForThrow; let assertLog; describe('ReactIncremental', () => { beforeEach(() => { jest.resetModules(); React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); PropTypes = require('prop-types'); ({ assertConsoleErrorDev, waitForAll, waitFor, waitForThrow, assertLog, } = require('internal-test-utils')); }); // Note: This is based on a similar component we use in www. We can delete // once the extra div wrapper is no longer necessary. function LegacyHiddenDiv({children, mode}) { return ( ); } it('should render a simple component', async () => { function Bar() { return
Hello World
; } function Foo() { return ; } ReactNoop.render(); await waitForAll([]); }); it('should render a simple component, in steps if needed', async () => { function Bar() { Scheduler.log('Bar'); return (
Hello World
); } function Foo() { Scheduler.log('Foo'); return [, ]; } React.startTransition(() => { ReactNoop.render(, () => Scheduler.log('callback')); }); // Do one step of work. await waitFor(['Foo']); // Do the rest of the work. await waitForAll(['Bar', 'Bar', 'callback']); }); it('updates a previous render', async () => { function Header() { Scheduler.log('Header'); return

Hi

; } function Content(props) { Scheduler.log('Content'); return
{props.children}
; } function Footer() { Scheduler.log('Footer'); return
Bye
; } const header =
; const footer =