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
81 lines
1.8 KiB
JavaScript
81 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 LogBoxInspectorMessageHeader = require('../LogBoxInspectorMessageHeader')
|
|
.default;
|
|
const render = require('../../../../jest/renderer');
|
|
|
|
describe('LogBoxInspectorMessageHeader', () => {
|
|
it('should not render error', () => {
|
|
const output = render.shallowRender(
|
|
<LogBoxInspectorMessageHeader
|
|
level="error"
|
|
collapsed={false}
|
|
message={{
|
|
content: 'Short',
|
|
substitutions: [],
|
|
}}
|
|
onPress={() => {}}
|
|
/>,
|
|
);
|
|
|
|
expect(output).toMatchSnapshot();
|
|
});
|
|
|
|
it('should not render collapse button for short content', () => {
|
|
const output = render.shallowRender(
|
|
<LogBoxInspectorMessageHeader
|
|
level="warn"
|
|
collapsed={false}
|
|
message={{
|
|
content: 'Short',
|
|
substitutions: [],
|
|
}}
|
|
onPress={() => {}}
|
|
/>,
|
|
);
|
|
|
|
expect(output).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render "collapse" if expanded', () => {
|
|
const output = render.shallowRender(
|
|
<LogBoxInspectorMessageHeader
|
|
level="warn"
|
|
collapsed={false}
|
|
message={{content: '#'.repeat(200), substitutions: []}}
|
|
onPress={() => {}}
|
|
/>,
|
|
);
|
|
|
|
expect(output).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render "see more" if collapsed', () => {
|
|
const output = render.shallowRender(
|
|
<LogBoxInspectorMessageHeader
|
|
level="warn"
|
|
collapsed={true}
|
|
message={{
|
|
content: '#'.repeat(200),
|
|
substitutions: [],
|
|
}}
|
|
onPress={() => {}}
|
|
/>,
|
|
);
|
|
|
|
expect(output).toMatchSnapshot();
|
|
});
|
|
});
|