mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
404f3ebde2
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51781 Adds `flow` to the remaining files that are lacking it in the `packages/react-native-codegen` directory. This also adds any necessary type annotations (using comment syntax). Changelog: [Internal] Reviewed By: huntie Differential Revision: D75884727 fbshipit-source-id: 69e880b2dc63c3d6430f841652506e57436544a8
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.
|
|
*
|
|
* @flow strict-local
|
|
* @format
|
|
*/
|
|
|
|
import failures from '../__test_fixtures__/failures.js';
|
|
import fixtures from '../__test_fixtures__/fixtures.js';
|
|
import {transformSync} from '@babel/core';
|
|
|
|
const transform = (fixture /*: string */, filename /*: string */) =>
|
|
transformSync(fixture, {
|
|
babelrc: false,
|
|
browserslistConfigFile: false,
|
|
cwd: '/',
|
|
filename,
|
|
highlightCode: false,
|
|
plugins: [
|
|
// $FlowFixMe[untyped-import]
|
|
require('@babel/plugin-syntax-flow'),
|
|
// $FlowFixMe[untyped-import]
|
|
require('../index'),
|
|
],
|
|
}).code;
|
|
|
|
describe('Babel plugin inline view configs', () => {
|
|
Object.keys(fixtures)
|
|
.sort()
|
|
.forEach(fixtureName => {
|
|
it(`can inline config for ${fixtureName}`, () => {
|
|
expect(transform(fixtures[fixtureName], fixtureName)).toMatchSnapshot();
|
|
});
|
|
});
|
|
|
|
Object.keys(failures)
|
|
.sort()
|
|
.forEach(fixtureName => {
|
|
it(`fails on inline config for ${fixtureName}`, () => {
|
|
expect(() => {
|
|
try {
|
|
transform(failures[fixtureName], fixtureName);
|
|
} catch (err) {
|
|
err.message = err.message.replace(/^[A-z]:\\/g, '/'); // Ensure platform consistent snapshots.
|
|
throw err;
|
|
}
|
|
}).toThrowErrorMatchingSnapshot();
|
|
});
|
|
});
|
|
});
|