RN: Migrate LogBoxInspectorCodeFrame-test.js from Shallow Renderer (#44979)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44979

Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58643061

fbshipit-source-id: 0c68324d4d92fc8818ac469737eda3679aa773b3
This commit is contained in:
Tim Yung
2024-06-16 10:30:39 -07:00
committed by Facebook GitHub Bot
parent 7dd4811bea
commit ba2e4a57e8
@@ -15,17 +15,34 @@ const render = require('../../../../jest/renderer');
const LogBoxInspectorCodeFrame = require('../LogBoxInspectorCodeFrame').default;
const React = require('react');
// Mock child components because we are interested in snapshotting the behavior
// of `LogBoxInspectorCodeFrame`, not its children.
jest.mock('../../../Components/ScrollView/ScrollView', () => ({
__esModule: true,
default: 'ScrollView',
}));
jest.mock('../AnsiHighlight', () => ({
__esModule: true,
default: 'Ansi',
}));
jest.mock('../LogBoxButton', () => ({
__esModule: true,
default: 'LogBoxButton',
}));
jest.mock('../LogBoxInspectorSection', () => ({
__esModule: true,
default: 'LogBoxInspectorSection',
}));
describe('LogBoxInspectorCodeFrame', () => {
it('should render null for no code frame', () => {
const output = render.shallowRender(
<LogBoxInspectorCodeFrame codeFrame={null} />,
);
const output = render.create(<LogBoxInspectorCodeFrame codeFrame={null} />);
expect(output).toMatchSnapshot();
});
it('should render a code frame', () => {
const output = render.shallowRender(
const output = render.create(
<LogBoxInspectorCodeFrame
codeFrame={{
fileName: '/path/to/RKJSModules/Apps/CrashReact/CrashReactApp.js',
@@ -43,7 +60,7 @@ describe('LogBoxInspectorCodeFrame', () => {
});
it('should render a code frame without a location', () => {
const output = render.shallowRender(
const output = render.create(
<LogBoxInspectorCodeFrame
codeFrame={{
fileName: '/path/to/RKJSModules/Apps/CrashReact/CrashReactApp.js',