-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathindex.js
45 lines (38 loc) · 1.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* External dependencies
*/
import path from 'path';
import { readFileSync } from 'fs';
import { transform } from '@babel/core';
/**
* Internal dependencies
*/
import babelPresetDefault from '../';
describe( 'Babel preset default', () => {
test( 'transpilation works properly', () => {
const filename = path.join( __dirname, '/fixtures/input.js' );
const input = readFileSync( filename );
const output = transform( input, {
filename,
configFile: false,
envName: 'production',
presets: [ babelPresetDefault ],
} );
expect( output.code ).toMatchSnapshot();
} );
test( 'transpilation includes magic comment when using the addPolyfillComments option', () => {
const filename = path.join( __dirname, '/fixtures/polyfill.js' );
const input = readFileSync( filename );
const output = transform( input, {
filename,
configFile: false,
envName: 'production',
presets: [ babelPresetDefault ],
caller: {
name: 'WP_BUILD_MAIN',
addPolyfillComments: true,
},
} );
expect( output.code ).toContain( '/* wp:polyfill */' );
} );
} );