Files
react-native/packages/react-native-codegen/e2e/__tests__/components/GeneratePropsJavaInterface-test.js
T
Ramanpreet Nara 857137dc21 Create E2E tests for Component Generators
Summary:
## Rationale
- We actually don't have E2E tests that test the parser + generator together, until now.
- **Documentation Value:** These tests show how the Component Spec files in [react-native-codegen/e2e/__test_fixtures__/](https://www.internalfb.com/code/fbsource/[e32a790dfa05]/xplat/js/react-native-github/packages/react-native-codegen/e2e/__test_fixtures__/components/) map to all the different types of codegen output.

Changelog: [Internal]

Reviewed By: sshic

Differential Revision: D32081445

fbshipit-source-id: 02cd17945ef63a42381d6d4adbd0a9b0eaa2a1ef
2021-11-02 10:54:11 -07:00

29 lines
920 B
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.
*
* @emails oncall+react_native
* @flow strict-local
* @format
*/
'use strict';
const parser = require('../../../src/parsers/flow');
const generator = require('../../../src/generators/components/GeneratePropsJavaInterface');
const fs = require('fs');
const FIXTURE_DIR = `${__dirname}/../../__test_fixtures__/components`;
const fixtures = fs.readdirSync(FIXTURE_DIR);
fixtures.forEach(fixture => {
it(`GeneratePropsJavaInterface can generate for '${fixture}'`, () => {
const libName = 'RNCodegenModuleFixtures';
const schema = parser.parseFile(`${FIXTURE_DIR}/${fixture}`);
const output = generator.generate(libName, schema, undefined, false);
expect(Object.fromEntries(output)).toMatchSnapshot();
});
});