@@ -11,7 +11,7 @@ describe('eval', () => {
1111 ` ,
1212 } ;
1313
14- expect ( evaller ( mainModule ) ) . toEqual ( { default : 3 } ) ;
14+ expect ( evaller ( mainModule , [ ] , [ ] ) ) . toEqual ( { default : 3 } ) ;
1515 } ) ;
1616
1717 test ( 'multiple es exports' , ( ) => {
@@ -24,7 +24,11 @@ describe('eval', () => {
2424 ` ,
2525 } ;
2626
27- expect ( evaller ( mainModule ) ) . toEqual ( { a : 'b' , b : 'c' , default : 3 } ) ;
27+ expect ( evaller ( mainModule , [ ] , [ ] ) ) . toEqual ( {
28+ a : 'b' ,
29+ b : 'c' ,
30+ default : 3 ,
31+ } ) ;
2832 } ) ;
2933
3034 test ( 'node exports' , ( ) => {
@@ -35,7 +39,7 @@ describe('eval', () => {
3539 ` ,
3640 } ;
3741
38- expect ( evaller ( mainModule ) ) . toEqual ( 3 ) ;
42+ expect ( evaller ( mainModule , [ ] , [ ] ) ) . toEqual ( 3 ) ;
3943 } ) ;
4044
4145 test ( 'imports' , ( ) => {
@@ -55,10 +59,105 @@ describe('eval', () => {
5559 ` ,
5660 } ;
5761
58- expect ( evaller ( mainModule , [ mainModule , secondModule ] ) ) . toEqual ( {
62+ expect ( evaller ( mainModule , [ mainModule , secondModule ] , [ ] ) ) . toEqual ( {
5963 default : 3 ,
6064 } ) ;
6165 } ) ;
66+
67+ describe . skip ( 'custom babel config' , ( ) => {
68+ it ( 'uses custom babel config' , ( ) => {
69+ const mainModule = {
70+ title : 'test.js' ,
71+ shortid : '1' ,
72+ code : `
73+ const a = {b: 'a'};
74+ const b = {a: 'b'};
75+ export default {...a, ...b};
76+ ` ,
77+ } ;
78+
79+ const babelConfig = {
80+ title : '.babelrc' ,
81+ shortid : '2' ,
82+ code : `
83+ {
84+ "presets": ["es2015", "react", "stage-0"]
85+ }
86+ ` ,
87+ } ;
88+
89+ expect ( evaller ( mainModule , [ mainModule , babelConfig ] , [ ] ) ) . toEqual ( {
90+ default : { a : 'b' , b : 'a' } ,
91+ } ) ;
92+
93+ const emptyBabelConfig = {
94+ title : '.babelrc' ,
95+ shortid : '2' ,
96+ code : `
97+ {
98+ "presets": []
99+ }` ,
100+ } ;
101+
102+ expect ( ( ) =>
103+ evaller ( mainModule , [ mainModule , emptyBabelConfig ] , [ ] ) ,
104+ ) . toThrow ( ) ;
105+ } ) ;
106+
107+ it ( 'resolves to dependencies as plugins' , ( ) => {
108+ const mainModule = {
109+ title : 'test.js' ,
110+ shortid : '1' ,
111+ code : `
112+ const a = {b: 'a'};
113+ const b = {a: 'b'};
114+ export default {...a, ...b};
115+ ` ,
116+ } ;
117+
118+ const babelConfig = {
119+ title : '.babelrc' ,
120+ shortid : '2' ,
121+ code : `
122+ {
123+ "presets": ["es2015", "react", "stage-0"],
124+ "plugins": ["emotion/babel"]
125+ }
126+ ` ,
127+ } ;
128+
129+ expect ( ( ) =>
130+ evaller ( mainModule , [ mainModule , babelConfig ] , [ ] , { } ) ,
131+ ) . toThrowError ( "Could not find dependency: 'emotion'" ) ;
132+ } ) ;
133+
134+ it ( 'can resolve plugins with options' , ( ) => {
135+ const mainModule = {
136+ title : 'test.js' ,
137+ shortid : '1' ,
138+ code : `
139+ const a = {b: 'a'};
140+ const b = {a: 'b'};
141+ export default {...a, ...b};
142+ ` ,
143+ } ;
144+
145+ const babelConfig = {
146+ title : '.babelrc' ,
147+ shortid : '2' ,
148+ code : `
149+ {
150+ "presets": ["es2015", "react", "stage-0"],
151+ "plugins": [["emotion/babel", { "inline": true }]]
152+ }
153+ ` ,
154+ } ;
155+
156+ expect ( ( ) =>
157+ evaller ( mainModule , [ mainModule , babelConfig ] , [ ] , { } ) ,
158+ ) . toThrowError ( "Could not find dependency: 'emotion'" ) ;
159+ } ) ;
160+ } ) ;
62161 } ) ;
63162
64163 test ( 'css' , ( ) => {
0 commit comments