Files
react-native/packages/babel-plugin-codegen/__tests__/index-test.js
T
Moti Zilberman d6e0bc714a Enable lint/sort-imports everywhere (#41334)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41334

TSIA.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D51025812

fbshipit-source-id: e10d437be775a6b80946483aa96460f34927f870
2023-11-06 12:59:38 -08:00

51 lines
1.4 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.
*
* @format
* @oncall react_native
*/
'use strict';
const failures = require('../__test_fixtures__/failures.js');
const fixtures = require('../__test_fixtures__/fixtures.js');
const {transform: babelTransform} = require('@babel/core');
const transform = (fixture, filename) =>
babelTransform(fixture, {
babelrc: false,
browserslistConfigFile: false,
cwd: '/',
filename: filename,
highlightCode: false,
plugins: [require('@babel/plugin-syntax-flow'), 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();
});
});
});