Files
react-native/packages/babel-plugin-codegen/__tests__/index-test.js
T
Micha Reiser 58a0f9b4e2 Upgrade babel from 7.12.3 -> 7.14.1
Summary:
Changelog:

[General] [Changed] Upgrade Babel from 7.12.3 to 7.14.1

Reviewed By: motiz88

Differential Revision: D27851184

fbshipit-source-id: 59326332d1d188f163cdb034556eea7808824360
2021-05-13 02:48:09 -07:00

51 lines
1.4 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
* @format
*/
'use strict';
const {transform: babelTransform} = require('@babel/core');
const fixtures = require('../__test_fixtures__/fixtures.js');
const failures = require('../__test_fixtures__/failures.js');
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();
});
});
});