mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
e7a4dbcefc
Summary: Add annotations to function parameters required for Flow's Local Type Inference project. This codemod prepares the codebase to match Flow's new typechecking algorithm. The new algorithm will make Flow more reliable and predicatable. Reviewed By: evanyeung Differential Revision: D37353648 fbshipit-source-id: e5a0c685ced85a8ff353d578b373f836b376bb28
54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @emails oncall+react_native
|
|
* @format
|
|
* @flow
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
import type {StackFrame} from '../../../Core/NativeExceptionsManager';
|
|
|
|
jest.mock('../../../Core/Devtools/symbolicateStackTrace');
|
|
|
|
const LogBoxSymbolication = require('../LogBoxSymbolication');
|
|
|
|
const symbolicateStackTrace: JestMockFn<
|
|
$ReadOnlyArray<Array<StackFrame>>,
|
|
Promise<Array<StackFrame>>,
|
|
> = (require('../../../Core/Devtools/symbolicateStackTrace'): any);
|
|
|
|
const createStack = (methodNames: Array<string>) =>
|
|
methodNames.map(methodName => ({
|
|
column: null,
|
|
file: 'file://path/to/file.js',
|
|
lineNumber: 1,
|
|
methodName,
|
|
}));
|
|
|
|
describe('LogBoxSymbolication', () => {
|
|
beforeEach(() => {
|
|
jest.resetModules();
|
|
symbolicateStackTrace.mockImplementation(async stack => stack);
|
|
});
|
|
|
|
it('symbolicates different stacks', () => {
|
|
LogBoxSymbolication.symbolicate(createStack(['A', 'B', 'C']));
|
|
LogBoxSymbolication.symbolicate(createStack(['D', 'E', 'F']));
|
|
|
|
expect(symbolicateStackTrace.mock.calls.length).toBe(2);
|
|
});
|
|
|
|
it('batch symbolicates equivalent stacks', () => {
|
|
const stack = createStack(['A', 'B', 'C']);
|
|
LogBoxSymbolication.symbolicate(stack);
|
|
LogBoxSymbolication.symbolicate(stack);
|
|
|
|
expect(symbolicateStackTrace.mock.calls.length).toBe(1);
|
|
});
|
|
});
|