Hide stack frames when they're empty

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
This commit is contained in:
Rick Hanlon 2019-11-01 16:05:02 -07:00 коммит произвёл Facebook Github Bot
Родитель f6b1fa3197
Коммит eefece4be6
3 изменённых файлов: 26 добавлений и 0 удалений

Просмотреть файл

@ -54,6 +54,11 @@ function LogBoxInspectorStackFrames(props: Props): React.Node {
return `Collapse ${collapsedCount} frames`;
}
}
if (props.log.getAvailableStack().length === 0) {
return null;
}
return (
<View style={stackStyles.section}>
<StackFrameHeader

Просмотреть файл

@ -43,6 +43,17 @@ const log = new LogBoxLog(
[],
);
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(
@ -51,4 +62,12 @@ describe('LogBoxInspectorStackFrame', () => {
expect(output).toMatchSnapshot();
});
it('should render null for empty stack frames', () => {
const output = render.shallowRender(
<LogBoxInspectorStackFrames onRetry={() => {}} log={logNoStackFrames} />,
);
expect(output).toMatchSnapshot();
});
});

Просмотреть файл

@ -1,5 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`LogBoxInspectorStackFrame should render null for empty stack frames 1`] = `null`;
exports[`LogBoxInspectorStackFrame should render stack frames with 1 frame collapsed 1`] = `
<View
style={