@@ -359,6 +359,70 @@ describe('WebpackConfig object', () => {
359
359
} ) ;
360
360
} ) ;
361
361
362
+ describe ( 'copyFiles' , ( ) => {
363
+ it ( 'Calling it add files to be copied' , ( ) => {
364
+ const config = createConfig ( ) ;
365
+
366
+ // With multiple config objects
367
+ config . copyFiles ( [
368
+ { from : './foo' , pattern : / .* / } ,
369
+ { from : './bar' , pattern : / a b c / , to : 'bar' , includeSubdirectories : false } ,
370
+ ] ) ;
371
+
372
+ // With a single config object
373
+ config . copyFiles ( { from : './baz' } ) ;
374
+
375
+ expect ( config . copyFilesConfigs ) . to . deep . equal ( [ {
376
+ from : './foo' ,
377
+ pattern : / .* / ,
378
+ to : '[path][name].[ext]' ,
379
+ includeSubdirectories : true
380
+ } , {
381
+ from : './bar' ,
382
+ pattern : / a b c / ,
383
+ to : 'bar' ,
384
+ includeSubdirectories : false
385
+ } , {
386
+ from : './baz' ,
387
+ pattern : / .* / ,
388
+ to : '[path][name].[ext]' ,
389
+ includeSubdirectories : true
390
+ } ] ) ;
391
+ } ) ;
392
+
393
+ it ( 'Calling it with an invalid parameter' , ( ) => {
394
+ const config = createConfig ( ) ;
395
+
396
+ expect ( ( ) => {
397
+ config . copyFiles ( 'foo' ) ;
398
+ } ) . to . throw ( 'must be called with either a config object or an array of config objects' ) ;
399
+
400
+ expect ( ( ) => {
401
+ config . copyFiles ( [ { from : 'foo' } , 'foo' ] ) ;
402
+ } ) . to . throw ( 'must be called with either a config object or an array of config objects' ) ;
403
+ } ) ;
404
+
405
+ it ( 'Calling it with a missing from key' , ( ) => {
406
+ const config = createConfig ( ) ;
407
+
408
+ expect ( ( ) => {
409
+ config . copyFiles ( { to : 'foo' } ) ;
410
+ } ) . to . throw ( 'must have a "from" property' ) ;
411
+
412
+ expect ( ( ) => {
413
+ config . copyFiles ( [ { from : 'foo' } , { to : 'foo' } ] ) ;
414
+ } ) . to . throw ( 'must have a "from" property' ) ;
415
+ } ) ;
416
+
417
+ it ( 'Calling it with an unknown config property' , ( ) => {
418
+ const config = createConfig ( ) ;
419
+
420
+ expect ( ( ) => {
421
+ config . copyFiles ( { from : 'images' , foo : 'foo' } ) ;
422
+ } ) . to . throw ( 'Invalid config option "foo"' ) ;
423
+ } ) ;
424
+ } ) ;
425
+
362
426
describe ( 'autoProvideVariables' , ( ) => {
363
427
it ( 'Calling multiple times merges' , ( ) => {
364
428
const config = createConfig ( ) ;
0 commit comments