main
js 49 lines 1.45 KB
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @emails react-core
8 * @jest-environment node
9 */
10
11 'use strict';
12
13 let React;
14 let ReactNoop;
15 let waitForAll;
16
17 // This is a new feature in Fiber so I put it in its own test file. It could
18 // probably move to one of the other test files once it is official.
19 describe('ReactTopLevelText', () => {
20 beforeEach(() => {
21 jest.resetModules();
22 React = require('react');
23 ReactNoop = require('react-noop-renderer');
24
25 const InternalTestUtils = require('internal-test-utils');
26 waitForAll = InternalTestUtils.waitForAll;
27 });
28
29 it('should render a component returning strings directly from render', async () => {
30 const Text = ({value}) => value;
31 ReactNoop.render(<Text value="foo" />);
32 await waitForAll([]);
33 expect(ReactNoop).toMatchRenderedOutput('foo');
34 });
35
36 it('should render a component returning numbers directly from render', async () => {
37 const Text = ({value}) => value;
38 ReactNoop.render(<Text value={10} />);
39 await waitForAll([]);
40 expect(ReactNoop).toMatchRenderedOutput('10');
41 });
42
43 it('should render a component returning bigints directly from render', async () => {
44 const Text = ({value}) => value;
45 ReactNoop.render(<Text value={10n} />);
46 await waitForAll([]);
47 expect(ReactNoop).toMatchRenderedOutput('10');
48 });
49 });