mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
9215980471
Summary: All our codegen JavaScript now simply uses libraryName instead of moduleSpecName. In our buck infra, we assign native_module_spec_name to libraryName. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D25842696 fbshipit-source-id: efd3af402585f9ad4ff3b593179147eea91cc331
51 lines
1.5 KiB
JavaScript
51 lines
1.5 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.
|
|
*
|
|
* @emails oncall+react_native
|
|
* @flow strict-local
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const parser = require('../../../src/parsers/flow');
|
|
const generator = require('../../../src/generators/modules/GenerateModuleObjCpp');
|
|
const fs = require('fs');
|
|
|
|
import type {SchemaType} from '../../../src/CodegenSchema';
|
|
|
|
const FIXTURE_DIR = `${__dirname}/../../__test_fixtures__/modules`;
|
|
|
|
function getModules(): SchemaType {
|
|
const filenames: Array<string> = fs.readdirSync(FIXTURE_DIR);
|
|
return filenames.reduce<SchemaType>(
|
|
(accumulator, file) => {
|
|
const schema = parser.parseFile(`${FIXTURE_DIR}/${file}`);
|
|
return {
|
|
modules: {
|
|
...accumulator.modules,
|
|
...schema.modules,
|
|
},
|
|
};
|
|
},
|
|
{modules: {}},
|
|
);
|
|
}
|
|
|
|
describe('GenerateModuleObjCpp', () => {
|
|
it('can generate a header file NativeModule specs', () => {
|
|
const libName = 'RNCodegenModuleFixtures';
|
|
const output = generator.generate(libName, getModules());
|
|
expect(output.get(libName + '.h')).toMatchSnapshot();
|
|
});
|
|
|
|
it('can generate an implementation file NativeModule specs', () => {
|
|
const libName = 'RNCodegenModuleFixtures';
|
|
const output = generator.generate(libName, getModules());
|
|
expect(output.get(libName + '-generated.mm')).toMatchSnapshot();
|
|
});
|
|
});
|