mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
eefece4be6
Summary: In the next diff we'll introduce syntax errors, which we don't show stackframes for since they don't make sense. This diff removes the Stack Frame section when there are no stack frames available. Changelog: [Internal] Reviewed By: motiz88 Differential Revision: D18278831 fbshipit-source-id: 0a6ad5c3b7fed76123b6ad3ccfc8f3f0b044bda2
74 lines
1.6 KiB
JavaScript
74 lines
1.6 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 LogBoxInspectorStackFrames = require('../LogBoxInspectorStackFrames')
|
|
.default;
|
|
const LogBoxLog = require('../../Data/LogBoxLog').default;
|
|
const render = require('../../../../jest/renderer');
|
|
|
|
const log = new LogBoxLog(
|
|
'warn',
|
|
{
|
|
content: 'Some kind of message (latest)',
|
|
substitutions: [],
|
|
},
|
|
[
|
|
{
|
|
column: 1,
|
|
file: 'dependency.js',
|
|
lineNumber: 1,
|
|
methodName: 'dep',
|
|
collapse: true,
|
|
},
|
|
{
|
|
column: 1,
|
|
file: 'app.js',
|
|
lineNumber: 1,
|
|
methodName: 'foo',
|
|
collapse: false,
|
|
},
|
|
],
|
|
'Some kind of message (latest)',
|
|
[],
|
|
);
|
|
|
|
const logNoStackFrames = new LogBoxLog(
|
|
'warn',
|
|
{
|
|
content: 'Some kind of message (latest)',
|
|
substitutions: [],
|
|
},
|
|
[],
|
|
'Some kind of message (latest)',
|
|
[],
|
|
);
|
|
|
|
describe('LogBoxInspectorStackFrame', () => {
|
|
it('should render stack frames with 1 frame collapsed', () => {
|
|
const output = render.shallowRender(
|
|
<LogBoxInspectorStackFrames onRetry={() => {}} log={log} />,
|
|
);
|
|
|
|
expect(output).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render null for empty stack frames', () => {
|
|
const output = render.shallowRender(
|
|
<LogBoxInspectorStackFrames onRetry={() => {}} log={logNoStackFrames} />,
|
|
);
|
|
|
|
expect(output).toMatchSnapshot();
|
|
});
|
|
});
|