mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: This diff adds and displays errors in LogBox. We will now toast both warnings and errors, open errors for inspection, and allow paginating through errors and warnings. Changelog: [Internal] Reviewed By: cpojer Differential Revision: D18091519 fbshipit-source-id: c155969dc505de5cfb0e95bb5a8221b9f8cfe4f7
85 lines
1.8 KiB
JavaScript
85 lines
1.8 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 LogBoxInspector = require('../LogBoxInspector').default;
|
|
const LogBoxLog = require('../../Data/LogBoxLog').default;
|
|
const render = require('../../../../jest/renderer');
|
|
|
|
const logs = [
|
|
new LogBoxLog(
|
|
'warn',
|
|
{
|
|
content: 'Some kind of message (first)',
|
|
substitutions: [],
|
|
},
|
|
[],
|
|
'Some kind of message (first)',
|
|
[],
|
|
),
|
|
new LogBoxLog(
|
|
'error',
|
|
{
|
|
content: 'Some kind of message (second)',
|
|
substitutions: [],
|
|
},
|
|
[],
|
|
'Some kind of message (second)',
|
|
[],
|
|
),
|
|
];
|
|
|
|
describe('LogBoxContainer', () => {
|
|
it('should render null with no logs', () => {
|
|
const output = render.shallowRender(
|
|
<LogBoxInspector
|
|
onDismiss={() => {}}
|
|
onMinimize={() => {}}
|
|
onChangeSelectedIndex={() => {}}
|
|
logs={[]}
|
|
selectedIndex={0}
|
|
/>,
|
|
);
|
|
|
|
expect(output).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render warning with selectedIndex 0', () => {
|
|
const output = render.shallowRender(
|
|
<LogBoxInspector
|
|
onDismiss={() => {}}
|
|
onMinimize={() => {}}
|
|
onChangeSelectedIndex={() => {}}
|
|
logs={logs}
|
|
selectedIndex={0}
|
|
/>,
|
|
);
|
|
|
|
expect(output).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render error with selectedIndex 1', () => {
|
|
const output = render.shallowRender(
|
|
<LogBoxInspector
|
|
onDismiss={() => {}}
|
|
onMinimize={() => {}}
|
|
onChangeSelectedIndex={() => {}}
|
|
logs={logs}
|
|
selectedIndex={1}
|
|
/>,
|
|
);
|
|
|
|
expect(output).toMatchSnapshot();
|
|
});
|
|
});
|