/** * Copyright (c) Facebook, Inc. and its 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 */ 'use strict'; const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMServerIntegrationTestUtils'); let React; let ReactDOM; let ReactDOMServer; let ReactTestUtils; function initModules() { // Reset warning cache. jest.resetModuleRegistry(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMServer = require('react-dom/server'); ReactTestUtils = require('react-dom/test-utils'); // Make them available to the helpers. return { ReactDOM, ReactDOMServer, ReactTestUtils, }; } const { resetModules, itClientRenders, renderIntoDom, serverRender, } = ReactDOMServerIntegrationUtils(initModules); describe('ReactDOMServerIntegrationUserInteraction', () => { let ControlledInput, ControlledTextArea, ControlledCheckbox, ControlledSelect; beforeEach(() => { resetModules(); ControlledInput = class extends React.Component { static defaultProps = { type: 'text', initialValue: 'Hello', }; constructor() { super(...arguments); this.state = {value: this.props.initialValue}; } handleChange(event) { if (this.props.onChange) { this.props.onChange(event); } this.setState({value: event.target.value}); } render() { return ( ); } }; ControlledTextArea = class extends React.Component { constructor() { super(); this.state = {value: 'Hello'}; } handleChange(event) { if (this.props.onChange) { this.props.onChange(event); } this.setState({value: event.target.value}); } render() { return (