mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
3f2691cf84
Summary: This PR aims to extract the parseFile function in the typescript and flow parsers. This is to solve the problem described [here](https://github.com/facebook/react-native/pull/35158#issuecomment-1298330753) and help with the work done in https://github.com/facebook/react-native/issues/34872. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Internal] [Changed] - Extract the parseFile function in the typescript and flow parsers Pull Request resolved: https://github.com/facebook/react-native/pull/35318 Test Plan: yarn flow: <img width="496" alt="image" src="https://user-images.githubusercontent.com/40902940/206518024-83084c3d-ab0d-4a04-810a-d40270add4b0.png"> yarn lint: <img width="495" alt="image" src="https://user-images.githubusercontent.com/40902940/206518076-9e07eafe-db61-4c6e-8aaa-f92f190cf4f3.png"> yarn test: <img width="389" alt="image" src="https://user-images.githubusercontent.com/40902940/206518118-5633b28c-b79b-4421-80f7-de1e03fb8ff2.png"> Reviewed By: cortinico Differential Revision: D41248581 Pulled By: cipolleschi fbshipit-source-id: f5b878a28a7de612fcdd1528f064b44f668503af
32 lines
913 B
JavaScript
32 lines
913 B
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
|
|
* @oncall react_native
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const {FlowParser} = require('../../../src/parsers/flow/parser');
|
|
const generator = require('../../../src/generators/components/GenerateViewConfigJs');
|
|
const fs = require('fs');
|
|
|
|
const FIXTURE_DIR = `${__dirname}/../../__test_fixtures__/components`;
|
|
|
|
const fixtures = fs.readdirSync(FIXTURE_DIR);
|
|
|
|
const parser = new FlowParser();
|
|
|
|
fixtures.forEach(fixture => {
|
|
it(`GenerateViewConfigJs can generate for '${fixture}'`, () => {
|
|
const libName = 'RNCodegenModuleFixtures';
|
|
const schema = parser.parseFile(`${FIXTURE_DIR}/${fixture}`);
|
|
const output = generator.generate(libName, schema);
|
|
expect(output).toMatchSnapshot();
|
|
});
|
|
});
|