@@ -6,6 +6,10 @@ let faucetJS = require("../../lib");
66let path = require ( "path" ) ;
77let assert = require ( "assert" ) ;
88
9+ let DEFAULT_OPTIONS = {
10+ browsers : { }
11+ } ;
12+
913describe ( "bundling" , _ => {
1014 it ( "should combine ES6 modules into a bundle" , ( ) => {
1115 let config = [ {
@@ -14,7 +18,7 @@ describe("bundling", _ => {
1418 } ] ;
1519 let assetManager = new MockAssetManager ( FIXTURES_DIR ) ;
1620
17- return faucetJS ( config , assetManager , { browsers : { } } ) .
21+ return faucetJS ( config , assetManager , DEFAULT_OPTIONS ) .
1822 then ( _ => {
1923 assetManager . assertWrites ( [ {
2024 filepath : path . resolve ( FIXTURES_DIR , "./dist/bundle.js" ) ,
@@ -35,7 +39,7 @@ console.log(\`[…] $\{util}\`); // eslint-disable-line no-console
3539 } ] ;
3640 let assetManager = new MockAssetManager ( FIXTURES_DIR ) ;
3741
38- return faucetJS ( config , assetManager , { browsers : { } } ) .
42+ return faucetJS ( config , assetManager , DEFAULT_OPTIONS ) .
3943 then ( _ => {
4044 assetManager . assertWrites ( [ {
4145 filepath : path . resolve ( FIXTURES_DIR , "./dist/bundle.js" ) ,
@@ -62,7 +66,7 @@ console.log("[\\u2026] " + util); // eslint-disable-line no-console
6266 } ] ;
6367 let assetManager = new MockAssetManager ( FIXTURES_DIR ) ;
6468
65- return faucetJS ( config , assetManager , { browsers : { } } ) .
69+ return faucetJS ( config , assetManager , DEFAULT_OPTIONS ) .
6670 then ( restore , restore ) . // XXX: hacky
6771 then ( _ => {
6872 assetManager . assertWrites ( [ {
@@ -103,7 +107,7 @@ console.log("[\\u2026] " + dist); // eslint-disable-line no-console
103107 } ] ;
104108 let assetManager = new MockAssetManager ( FIXTURES_DIR ) ;
105109
106- return faucetJS ( config , assetManager , { browsers : { } } ) .
110+ return faucetJS ( config , assetManager , DEFAULT_OPTIONS ) .
107111 then ( _ => {
108112 assetManager . assertWrites ( [ {
109113 filepath : path . resolve ( FIXTURES_DIR , "./dist/bundle.js" ) ,
@@ -124,7 +128,7 @@ console.log(\`[…] $\{helper}\`); // eslint-disable-line no-console
124128 } ] ;
125129 let assetManager = new MockAssetManager ( FIXTURES_DIR ) ;
126130
127- return faucetJS ( config , assetManager , { browsers : { } } ) .
131+ return faucetJS ( config , assetManager , DEFAULT_OPTIONS ) .
128132 then ( _ => {
129133 assetManager . assertWrites ( [ {
130134 filepath : path . resolve ( FIXTURES_DIR , "./dist/bundle.js" ) ,
@@ -149,7 +153,7 @@ return lib;
149153 } ] ;
150154 let assetManager = new MockAssetManager ( FIXTURES_DIR ) ;
151155
152- return faucetJS ( config , assetManager , { browsers : { } } ) .
156+ return faucetJS ( config , assetManager , DEFAULT_OPTIONS ) .
153157 then ( _ => {
154158 assetManager . assertWrites ( [ {
155159 filepath : path . resolve ( FIXTURES_DIR , "./dist/bundle.js" ) ,
@@ -181,7 +185,7 @@ return lib;
181185 } ] ;
182186 let assetManager = new MockAssetManager ( FIXTURES_DIR ) ;
183187
184- return faucetJS ( config , assetManager , { browsers : { } } ) .
188+ return faucetJS ( config , assetManager , DEFAULT_OPTIONS ) .
185189 then ( _ => {
186190 assetManager . assertWrites ( [ {
187191 filepath : path . resolve ( FIXTURES_DIR , "./dist/bundle.js" ) ,
@@ -202,7 +206,7 @@ console.log(\`[…] $\{MYLIB}\`); // eslint-disable-line no-console
202206 } ] ;
203207 let assetManager = new MockAssetManager ( FIXTURES_DIR ) ;
204208
205- return faucetJS ( config , assetManager , { browsers : { } } ) .
209+ return faucetJS ( config , assetManager , DEFAULT_OPTIONS ) .
206210 then ( _ => {
207211 assetManager . assertWrites ( [ {
208212 filepath : path . resolve ( FIXTURES_DIR , "./dist/bundle.js" ) ,
@@ -304,7 +308,8 @@ console.log(\`[…] $\{util}\`); // eslint-disable-line no-console
304308 } ] ;
305309 let assetManager = new MockAssetManager ( FIXTURES_DIR ) ;
306310
307- return faucetJS ( config , assetManager , { browsers : { } , compact : true } ) .
311+ let options = { browsers : { } , compact : true } ;
312+ return faucetJS ( config , assetManager , options ) .
308313 then ( _ => {
309314 assetManager . assertWrites ( [ {
310315 filepath : path . resolve ( FIXTURES_DIR , "./dist/bundle.js" ) ,
@@ -317,7 +322,7 @@ console.log(\`[…] $\{util}\`);
317322
318323 config [ 0 ] . esnext = true ;
319324 assetManager = new MockAssetManager ( FIXTURES_DIR ) ;
320- return faucetJS ( config , assetManager , { browsers : { } , compact : true } ) ;
325+ return faucetJS ( config , assetManager , options ) ;
321326 } ) .
322327 then ( _ => {
323328 assetManager . assertWrites ( [ {
@@ -331,7 +336,7 @@ console.log("[\\u2026] " + util);
331336
332337 config [ 0 ] . compact = false ; // overrides global option
333338 assetManager = new MockAssetManager ( FIXTURES_DIR ) ;
334- return faucetJS ( config , assetManager , { browsers : { } , compact : true } ) ;
339+ return faucetJS ( config , assetManager , options ) ;
335340 } ) .
336341 then ( _ => {
337342 assetManager . assertWrites ( [ {
@@ -350,7 +355,7 @@ console.log("[\\u2026] " + util); // eslint-disable-line no-console
350355 let entryPoint = "src/index.js" ;
351356 let target = "dist/bundle.js" ;
352357 let compile = ( source , target ) => faucetJS ( [ { source, target } ] ,
353- assetManager , { browsers : { } } ) ;
358+ assetManager , DEFAULT_OPTIONS ) ;
354359
355360 let fn = _ => compile ( `./${ entryPoint } ` , target ) ;
356361 assert . throws ( fn , / p a t h m u s t b e r e l a t i v e / ) ;
@@ -368,7 +373,7 @@ console.log("[\\u2026] " + util); // eslint-disable-line no-console
368373 let target = "./dist/bundle.js" ;
369374 let assetManager = new MockAssetManager ( FIXTURES_DIR ) ;
370375 let compile = ( source , target ) => faucetJS ( [ { source, target } ] ,
371- assetManager , { browsers : { } } ) ;
376+ assetManager , DEFAULT_OPTIONS ) ;
372377
373378 return compile ( entryPoint , target ) .
374379 then ( _ => {
0 commit comments