1
+ import * as copy from './copy' ;
2
+
3
+ import * as config from './util/config' ;
4
+
5
+ describe ( 'copy task' , ( ) => {
6
+ describe ( 'copyConfigToWatchConfig' , ( ) => {
7
+ it ( 'should do something' , ( ) => {
8
+ // arrange
9
+ const context = { } ;
10
+ const configFile = 'configFile' ;
11
+ const sampleConfig : copy . CopyConfig = {
12
+ copyAssets : {
13
+ src : [ '{{SRC}}/assets/**/*' ] ,
14
+ dest : '{{WWW}}/assets'
15
+ } ,
16
+ copyIndexContent : {
17
+ src : [ '{{SRC}}/index.html' , '{{SRC}}/manifest.json' , '{{SRC}}/service-worker.js' ] ,
18
+ dest : '{{WWW}}'
19
+ } ,
20
+ copyFonts : {
21
+ src : [ '{{ROOT}}/node_modules/ionicons/dist/fonts/**/*' , '{{ROOT}}/node_modules/ionic-angular/fonts/**/*' ] ,
22
+ dest : '{{WWW}}/assets/fonts'
23
+ } ,
24
+ copyPolyfills : {
25
+ src : [ '{{ROOT}}/node_modules/ionic-angular/polyfills/polyfills.js' ] ,
26
+ dest : '{{BUILD}}'
27
+ } ,
28
+ someOtherOption : {
29
+ src : [ '{{ROOT}}/whatever' ] ,
30
+ dest : '{{BUILD}}'
31
+ }
32
+ } ;
33
+ let combinedSource : string [ ] = [ ] ;
34
+ Object . keys ( sampleConfig ) . forEach ( entry => combinedSource = combinedSource . concat ( sampleConfig [ entry ] . src ) ) ;
35
+
36
+ spyOn ( config , config . generateContext . name ) . and . returnValue ( context ) ;
37
+ spyOn ( config , config . getUserConfigFile . name ) . and . returnValue ( configFile ) ;
38
+ spyOn ( config , config . fillConfigDefaults . name ) . and . returnValue ( sampleConfig ) ;
39
+
40
+ // act
41
+ const result = copy . copyConfigToWatchConfig ( null ) ;
42
+
43
+ // assert
44
+ expect ( config . generateContext ) . toHaveBeenCalledWith ( null ) ;
45
+ expect ( config . getUserConfigFile ) . toHaveBeenCalledWith ( context , copy . taskInfo , '' ) ;
46
+ expect ( config . fillConfigDefaults ) . toHaveBeenCalledWith ( configFile , copy . taskInfo . defaultConfigFile ) ;
47
+ ( result . paths as string [ ] ) . forEach ( glob => {
48
+ expect ( combinedSource . indexOf ( glob ) ) . not . toEqual ( - 1 ) ;
49
+ } ) ;
50
+ expect ( result . callback ) . toBeDefined ( ) ;
51
+ expect ( result . options ) . toBeDefined ( ) ;
52
+ } ) ;
53
+ } ) ;
54
+ } ) ;
0 commit comments