1+ /*globals describe it */
12var should = require ( "should" ) ;
23var path = require ( "path" ) ;
34
@@ -6,9 +7,7 @@ var webpack = require("../lib/webpack");
67var base = path . join ( __dirname , "fixtures" , "errors" ) ;
78
89describe ( "Errors" , function ( ) {
9- function getErrors ( options , callback ) {
10- options . context = base ;
11- var c = webpack ( options ) ;
10+ function customOutputFilesystem ( c ) {
1211 var files = { } ;
1312 c . outputFileSystem = {
1413 join : path . join . bind ( path ) ,
@@ -20,15 +19,21 @@ describe("Errors", function() {
2019 callback ( ) ;
2120 }
2221 } ;
22+ return files ;
23+ }
24+ function getErrors ( options , callback ) {
25+ options . context = base ;
26+ var c = webpack ( options ) ;
27+ customOutputFilesystem ( c ) ;
2328 c . run ( function ( err , stats ) {
2429 if ( err ) throw err ;
2530 should . strictEqual ( typeof stats , "object" ) ;
2631 stats = stats . toJson ( { errorDetails : false } ) ;
2732 should . strictEqual ( typeof stats , "object" ) ;
2833 stats . should . have . property ( "errors" ) ;
2934 stats . should . have . property ( "warnings" ) ;
30- Array . isArray ( stats . errors ) . should . be . ok ;
31- Array . isArray ( stats . warnings ) . should . be . ok ;
35+ Array . isArray ( stats . errors ) . should . be . ok ; // eslint-disable-line no-unused-expressions
36+ Array . isArray ( stats . warnings ) . should . be . ok ; // eslint-disable-line no-unused-expressions
3237 callback ( stats . errors , stats . warnings ) ;
3338 } ) ;
3439 }
@@ -44,7 +49,7 @@ describe("Errors", function() {
4449 lines [ 1 ] . should . match ( / ^ M o d u l e n o t f o u n d / ) ;
4550 lines [ 1 ] . should . match ( / \. \/ d i r \/ m i s s i n g 2 / ) ;
4651 lines [ 2 ] . should . match ( / m i s s i n g F i l e .j s 1 2 : 9 / ) ;
47- var lines = errors [ 1 ] . split ( "\n" ) ;
52+ lines = errors [ 1 ] . split ( "\n" ) ;
4853 lines [ 0 ] . should . match ( / m i s s i n g F i l e .j s / ) ;
4954 lines [ 1 ] . should . match ( / ^ M o d u l e n o t f o u n d / ) ;
5055 lines [ 1 ] . should . match ( / \. \/ m i s s i n g / ) ;
@@ -101,4 +106,25 @@ describe("Errors", function() {
101106 done ( ) ;
102107 } ) ;
103108 } ) ;
109+ it ( "should throw an error when using incorrect CommonsChunkPlugin configuration" , function ( done ) {
110+ getErrors ( {
111+ entry : {
112+ a : "./entry-point" ,
113+ b : "./entry-point" ,
114+ c : "./entry-point"
115+ } ,
116+ plugins : [
117+ new webpack . optimize . CommonsChunkPlugin ( "a" , "a.js" , Infinity ) ,
118+ new webpack . optimize . CommonsChunkPlugin ( "b" , "b.js" , Infinity )
119+ ]
120+ } , function ( errors , warnings ) {
121+ errors . length . should . be . eql ( 1 ) ;
122+ warnings . length . should . be . eql ( 0 ) ;
123+ var lines = errors [ 0 ] . split ( "\n" ) ;
124+ lines [ 0 ] . should . match ( / C o m m o n s C h u n k P l u g i n / ) ;
125+ lines [ 0 ] . should . match ( / n o n - e n t r y / ) ;
126+ done ( ) ;
127+ } ) ;
128+
129+ } ) ;
104130} ) ;
0 commit comments