Files
react-native/Libraries/LogBox/UI/__tests__/LogBoxMessage-test.js
T
Rick Hanlon 41b0d0a672 LogBox - Clean up and test message substitutions
Summary:
This diff cleans up some of the message substitution logic and adds unit tests

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D18056241

fbshipit-source-id: 6173961c049071ab8aeff6cd273bd3590ee21e60
2019-10-22 14:13:19 -07:00

75 lines
1.7 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 LogBoxMessage = require('../LogBoxMessage').default;
const render = require('../../../../jest/renderer');
describe('LogBoxMessage', () => {
it('should render message', () => {
const output = render.shallowRender(
<LogBoxMessage
style={{}}
message={{
content: 'Some kind of message',
substitutions: [],
}}
/>,
);
expect(output).toMatchSnapshot();
});
it('should render message with substitution', () => {
const output = render.shallowRender(
<LogBoxMessage
style={{}}
message={{
content: 'normal substitution normal',
substitutions: [{length: 12, offset: 7}],
}}
/>,
);
expect(output).toMatchSnapshot();
});
it('Should strip "Warning: " without breaking substitution', () => {
const output = render.shallowRender(
<LogBoxMessage
style={{}}
message={{
content: 'Warning: normal substitution normal',
substitutions: [{length: 12, offset: 16}],
}}
/>,
);
expect(output).toMatchSnapshot();
});
it('Should strip "Warning: Warning: " without breaking substitution', () => {
const output = render.shallowRender(
<LogBoxMessage
style={{}}
message={{
content: 'Warning: Warning: normal substitution normal',
substitutions: [{length: 12, offset: 25}],
}}
/>,
);
expect(output).toMatchSnapshot();
});
});