Files
react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorCodeFrame-test.js
T
Rick Hanlon 7ad862eaba LogBox - Press to open code frame file
Summary:
This diff adds the ability to press the file name of a code frame to open the file in your editor.

Note: I re-worked the frame location to extract the frame row and column at parse time so that we don't need to do any clowny regexes down stream.

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D18358283

fbshipit-source-id: 705e07d229c66ecfd225a8fb65ef2f78b5034c9c
2019-11-07 09:11:59 -08:00

45 lines
1.1 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();
});
});