main
js 30 lines 821 Bytes
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 'use strict';
8
9 describe('transform-lazy-jsx-import', () => {
10 it('should use the mocked version of the "react" runtime in jsx', () => {
11 jest.resetModules();
12 const mock = jest.fn(type => 'fakejsx: ' + type);
13 if (__DEV__) {
14 jest.mock('react/jsx-dev-runtime', () => {
15 return {
16 jsxDEV: mock,
17 };
18 });
19 } else {
20 jest.mock('react/jsx-runtime', () => ({
21 jsx: mock,
22 jsxs: mock,
23 }));
24 }
25 // eslint-disable-next-line react/react-in-jsx-scope
26 const x = <div />;
27 expect(x).toBe('fakejsx: div');
28 expect(mock).toHaveBeenCalledTimes(1);
29 });
30 });