ReactDOMOption-test.js — react Source File
Architecture documentation for ReactDOMOption-test.js, a javascript file in the react codebase.
Entity Profile
Source Code
/**
* 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
*/
'use strict';
describe('ReactDOMOption', () => {
let React;
let ReactDOMClient;
let ReactDOMServer;
let act;
let assertConsoleErrorDev;
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactDOMClient = require('react-dom/client');
ReactDOMServer = require('react-dom/server');
act = require('internal-test-utils').act;
assertConsoleErrorDev =
require('internal-test-utils').assertConsoleErrorDev;
});
async function renderIntoDocument(children) {
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);
await act(async () => root.render(children));
return container;
}
it('should flatten children to a string', async () => {
const stub = (
<option>
{1} {'foo'}
</option>
);
const container = await renderIntoDocument(stub);
expect(container.firstChild.innerHTML).toBe('1 foo');
});
it('should warn for invalid child tags', async () => {
const el = (
<option value="12">
{1} <div /> {2}
</option>
);
const container = await renderIntoDocument(el);
assertConsoleErrorDev([
'In HTML, <div> cannot be a child of <option>.\n' +
'This will cause a hydration error.\n' +
'\n' +
'> <option value="12">\n' +
'> <div>\n' +
' ...\n' +
// ... (229 more lines)
Source
Frequently Asked Questions
What does ReactDOMOption-test.js do?
ReactDOMOption-test.js is a source file in the react codebase, written in javascript.
Where is ReactDOMOption-test.js in the architecture?
ReactDOMOption-test.js is located at packages/react-dom/src/__tests__/ReactDOMOption-test.js (directory: packages/react-dom/src/__tests__).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free