2019-01-23 03:04:37 +08:00
|
|
|
/** @flow */
|
|
|
|
|
|
2019-02-14 03:22:22 +08:00
|
|
|
// This test harness mounts each test app as a separate root to test multi-root applications.
|
|
|
|
|
|
2019-01-23 03:04:37 +08:00
|
|
|
import { createElement } from 'react';
|
2019-05-16 06:36:14 +08:00
|
|
|
import {
|
|
|
|
|
// $FlowFixMe Flow does not yet know about createRoot()
|
|
|
|
|
unstable_createRoot as createRoot,
|
|
|
|
|
} from 'react-dom';
|
2019-02-28 05:05:43 +08:00
|
|
|
import DeeplyNestedComponents from './DeeplyNestedComponents';
|
2019-02-18 05:07:39 +08:00
|
|
|
import EditableProps from './EditableProps';
|
2019-02-14 03:22:22 +08:00
|
|
|
import ElementTypes from './ElementTypes';
|
2019-06-18 05:37:49 +08:00
|
|
|
import Hydration from './Hydration';
|
2019-02-14 03:22:22 +08:00
|
|
|
import InspectableElements from './InspectableElements';
|
2019-03-25 00:21:37 +08:00
|
|
|
import InteractionTracing from './InteractionTracing';
|
2019-05-16 06:36:14 +08:00
|
|
|
import PriorityLevels from './PriorityLevels';
|
2019-02-14 03:22:22 +08:00
|
|
|
import ToDoList from './ToDoList';
|
2019-04-06 01:18:39 +08:00
|
|
|
import Toggle from './Toggle';
|
2019-04-05 07:29:47 +08:00
|
|
|
import SuspenseTree from './SuspenseTree';
|
2019-01-23 03:04:37 +08:00
|
|
|
|
2019-02-28 05:05:43 +08:00
|
|
|
import './styles.css';
|
|
|
|
|
|
2019-05-23 01:19:26 +08:00
|
|
|
const roots = [];
|
2019-01-23 03:04:37 +08:00
|
|
|
|
2019-02-14 03:22:22 +08:00
|
|
|
function mountHelper(App) {
|
|
|
|
|
const container = document.createElement('div');
|
|
|
|
|
|
|
|
|
|
((document.body: any): HTMLBodyElement).appendChild(container);
|
|
|
|
|
|
2019-05-16 06:36:14 +08:00
|
|
|
const root = createRoot(container);
|
|
|
|
|
root.render(createElement(App));
|
2019-05-23 01:19:26 +08:00
|
|
|
|
|
|
|
|
roots.push(root);
|
2019-01-27 23:58:09 +08:00
|
|
|
}
|
|
|
|
|
|
2019-02-14 03:22:22 +08:00
|
|
|
function mountTestApp() {
|
|
|
|
|
mountHelper(ToDoList);
|
2019-03-25 00:21:37 +08:00
|
|
|
mountHelper(InteractionTracing);
|
2019-02-14 03:22:22 +08:00
|
|
|
mountHelper(InspectableElements);
|
2019-06-18 05:37:49 +08:00
|
|
|
mountHelper(Hydration);
|
2019-02-14 03:22:22 +08:00
|
|
|
mountHelper(ElementTypes);
|
2019-02-18 05:07:39 +08:00
|
|
|
mountHelper(EditableProps);
|
2019-05-16 06:36:14 +08:00
|
|
|
mountHelper(PriorityLevels);
|
2019-04-06 01:18:39 +08:00
|
|
|
mountHelper(Toggle);
|
2019-04-05 07:29:47 +08:00
|
|
|
mountHelper(SuspenseTree);
|
2019-02-28 05:05:43 +08:00
|
|
|
mountHelper(DeeplyNestedComponents);
|
2019-02-14 03:22:22 +08:00
|
|
|
}
|
|
|
|
|
|
2019-01-27 23:58:09 +08:00
|
|
|
function unmountTestApp() {
|
2019-05-23 01:19:26 +08:00
|
|
|
roots.forEach(root => root.unmount());
|
2019-01-27 23:58:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mountTestApp();
|
|
|
|
|
|
|
|
|
|
window.parent.mountTestApp = mountTestApp;
|
|
|
|
|
window.parent.unmountTestApp = unmountTestApp;
|