mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
5a943ec235
Summary: Fixes an issue in LogBox that allowed users to try to dismiss warnings/errors when there was a fatal or syntax error up. Changelog: [Internal] Reviewed By: motiz88 Differential Revision: D18285678 fbshipit-source-id: 9d137fab63405c28b2bfa94a35c11c2f63b6d085
96 lines
2.0 KiB
JavaScript
96 lines
2.0 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)',
|
|
[],
|
|
),
|
|
new LogBoxLog(
|
|
'fatal',
|
|
{
|
|
content: 'Some kind of message (third)',
|
|
substitutions: [],
|
|
},
|
|
[],
|
|
'Some kind of message (third)',
|
|
[],
|
|
),
|
|
];
|
|
|
|
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 fatal with selectedIndex 2', () => {
|
|
const output = render.shallowRender(
|
|
<LogBoxInspector
|
|
onDismiss={() => {}}
|
|
onMinimize={() => {}}
|
|
onChangeSelectedIndex={() => {}}
|
|
logs={logs}
|
|
selectedIndex={2}
|
|
fatalType="fatal"
|
|
/>,
|
|
);
|
|
|
|
expect(output).toMatchSnapshot();
|
|
});
|
|
});
|