@@ -3,6 +3,7 @@ import fs from 'fs'
3
3
import { transformFileSync } from 'babel-core'
4
4
/* eslint-disable import/no-unresolved, import/extensions */
5
5
import { getOptions , TARGETS } from '../testConfig/babel'
6
+ import plugin from '../src/babel.dev'
6
7
/* eslint-enable import/no-unresolved, import/extensions */
7
8
8
9
const babelPlugin = path . resolve ( __dirname , '../src/babel.dev' )
@@ -61,4 +62,26 @@ describe('babel', () => {
61
62
} )
62
63
} )
63
64
} )
65
+
66
+ describe ( 'babel helpers' , ( ) => {
67
+ const { shouldIgnoreFile } = plugin
68
+ it ( 'should ignore react and hot-loader' , ( ) => {
69
+ expect ( shouldIgnoreFile ( 'node_modules/react' ) ) . toBe ( true )
70
+ expect ( shouldIgnoreFile ( 'node_modules\\react' ) ) . toBe ( true )
71
+ expect ( shouldIgnoreFile ( 'node_modules/react/xyz' ) ) . toBe ( true )
72
+
73
+ expect ( shouldIgnoreFile ( 'node_modules/react-hot-loader' ) ) . toBe ( true )
74
+ expect ( shouldIgnoreFile ( 'node_modules/react-hot-loader/xyz' ) ) . toBe ( true )
75
+ } )
76
+
77
+ it ( 'should pass all other files' , ( ) => {
78
+ expect ( shouldIgnoreFile ( 'react' ) ) . toBe ( false )
79
+ expect ( shouldIgnoreFile ( 'node_modules/react-select' ) ) . toBe ( false )
80
+ expect ( shouldIgnoreFile ( 'node_modules\\react-select' ) ) . toBe ( false )
81
+ expect ( shouldIgnoreFile ( 'some_modules/react/xyz' ) ) . toBe ( false )
82
+
83
+ expect ( shouldIgnoreFile ( 'node_modules/react-cold-loader' ) ) . toBe ( false )
84
+ expect ( shouldIgnoreFile ( 'react-hot-loader.js' ) ) . toBe ( false )
85
+ } )
86
+ } )
64
87
} )
0 commit comments