Files
react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorCodeFrame-test.js
T
Rick Hanlon 178f126d83 Parse any babel codeframe error as syntax error
Summary:
## Overview

This diff adds handling for syntax errors created using `buildCodeFrameError` which have a slightly different format than syntax errors thrown during transforms.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D18658502

fbshipit-source-id: 0836f2c16cdd57c10ed1e03dc7345d8e1ccf53f3
2019-11-27 09:25:04 -08:00

63 lines
1.5 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @emails oncall+react_native
* @flow
*/
'use strict';
const React = require('react');
const LogBoxInspectorCodeFrame = require('../LogBoxInspectorCodeFrame').default;
const render = require('../../../../jest/renderer');
describe('LogBoxInspectorCodeFrame', () => {
it('should render null for no code frame', () => {
const output = render.shallowRender(
<LogBoxInspectorCodeFrame codeFrame={null} />,
);
expect(output).toMatchSnapshot();
});
it('should render a code frame', () => {
const output = render.shallowRender(
<LogBoxInspectorCodeFrame
codeFrame={{
fileName: '/path/to/RKJSModules/Apps/CrashReact/CrashReactApp.js',
location: {row: 199, column: 0},
content: ` 197 | });
198 |
> 199 | export default CrashReactApp;
| ^
200 |`,
}}
/>,
);
expect(output).toMatchSnapshot();
});
it('should render a code frame without a location', () => {
const output = render.shallowRender(
<LogBoxInspectorCodeFrame
codeFrame={{
fileName: '/path/to/RKJSModules/Apps/CrashReact/CrashReactApp.js',
location: null,
content: ` 197 | });
198 |
> 199 | export default CrashReactApp;
| ^
200 |`,
}}
/>,
);
expect(output).toMatchSnapshot();
});
});