mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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:
committed by
Facebook GitHub Bot
parent
7dd4811bea
commit
ba2e4a57e8
+22
-5
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user