/**
* 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
* @jest-environment node
*/
'use strict';
let React;
let ReactDOMServer;
let PropTypes;
let ReactCurrentDispatcher;
let enableSuspenseServerRenderer = require('shared/ReactFeatureFlags')
.enableSuspenseServerRenderer;
function normalizeCodeLocInfo(str) {
return str && str.replace(/\(at .+?:\d+\)/g, '(at **)');
}
describe('ReactDOMServer', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
PropTypes = require('prop-types');
ReactDOMServer = require('react-dom/server');
ReactCurrentDispatcher =
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
.ReactCurrentDispatcher;
});
describe('renderToString', () => {
it('should generate simple markup', () => {
const response = ReactDOMServer.renderToString(hello world);
expect(response).toMatch(
new RegExp('hello world'),
);
});
it('should generate simple markup for self-closing tags', () => {
const response = ReactDOMServer.renderToString();
expect(response).toMatch(new RegExp('
'));
});
it('should generate comment markup for component returns null', () => {
class NullComponent extends React.Component {
render() {
return null;
}
}
const response = ReactDOMServer.renderToString(
');
}
});
it('warns about lowercase html but not in svg tags', () => {
function CompositeG(props) {
// Make sure namespace passes through composites
return