@@ -8,9 +8,11 @@ let buildThemes = require("../../../lib/tasks/buildThemes");
88test . beforeEach ( ( t ) => {
99 // Stubbing processors/themeBuilder
1010 t . context . themeBuilderStub = sinon . stub ( ) ;
11+ t . context . cssOptimizerStub = sinon . stub ( ) ;
1112 t . context . fsInterfaceStub = sinon . stub ( require ( "@ui5/fs" ) , "fsInterface" ) ;
1213 t . context . fsInterfaceStub . returns ( { } ) ;
1314 mock ( "../../../lib/processors/themeBuilder" , t . context . themeBuilderStub ) ;
15+ mock ( "../../../lib/processors/cssOptimizer" , t . context . cssOptimizerStub ) ;
1416
1517 // Re-require tested module
1618 buildThemes = mock . reRequire ( "../../../lib/tasks/buildThemes" ) ;
@@ -19,10 +21,11 @@ test.beforeEach((t) => {
1921test . afterEach . always ( ( t ) => {
2022 t . context . fsInterfaceStub . restore ( ) ;
2123 mock . stop ( "../../../lib/processors/themeBuilder" ) ;
24+ mock . stop ( "../../../lib/processors/cssOptimizer" ) ;
2225} ) ;
2326
2427test . serial ( "buildThemes" , async ( t ) => {
25- t . plan ( 6 ) ;
28+ t . plan ( 8 ) ;
2629
2730 const lessResource = { } ;
2831
@@ -37,9 +40,9 @@ test.serial("buildThemes", async (t) => {
3740 write : sinon . stub ( )
3841 } ;
3942
40- const cssResource = { } ;
41- const cssRtlResource = { } ;
42- const jsonParametersResource = { } ;
43+ const cssResource = { getPath : ( ) => "fu.css" } ;
44+ const cssRtlResource = { getPath : ( ) => "fu-rtl.css" } ;
45+ const jsonParametersResource = { getPath : ( ) => "fu.json" } ;
4346
4447 t . context . themeBuilderStub . returns ( [
4548 cssResource ,
@@ -56,15 +59,22 @@ test.serial("buildThemes", async (t) => {
5659 } ) ;
5760
5861 t . deepEqual ( t . context . themeBuilderStub . callCount , 1 ,
59- "Processor should be called once" ) ;
62+ "Theme Builder should be called once" ) ;
6063
6164 t . deepEqual ( t . context . themeBuilderStub . getCall ( 0 ) . args [ 0 ] , {
6265 resources : [ lessResource ] ,
6366 fs : { } ,
6467 options : {
65- compress : true // default
68+ compressJSON : true , // default
69+ compress : false
6670 }
67- } , "Processor should be called with expected arguments" ) ;
71+ } , "Theme Builder should be called with expected arguments" ) ;
72+
73+ t . deepEqual ( t . context . cssOptimizerStub . callCount , 1 , "CSS Optimizer should be called once" ) ;
74+ t . deepEqual ( t . context . cssOptimizerStub . getCall ( 0 ) . args [ 0 ] , {
75+ resources : [ cssResource , cssRtlResource ] ,
76+ fs : { }
77+ } , "CSS Optimizer should be called with expected arguments" ) ;
6878
6979 t . deepEqual ( workspace . write . callCount , 3 ,
7080 "workspace.write should be called 3 times" ) ;
@@ -75,7 +85,7 @@ test.serial("buildThemes", async (t) => {
7585
7686
7787test . serial ( "buildThemes (compress = false)" , async ( t ) => {
78- t . plan ( 6 ) ;
88+ t . plan ( 7 ) ;
7989
8090 const lessResource = { } ;
8191
@@ -90,9 +100,9 @@ test.serial("buildThemes (compress = false)", async (t) => {
90100 write : sinon . stub ( )
91101 } ;
92102
93- const cssResource = { } ;
94- const cssRtlResource = { } ;
95- const jsonParametersResource = { } ;
103+ const cssResource = { getPath : ( ) => "fu.css" } ;
104+ const cssRtlResource = { getPath : ( ) => "fu-rtl.css" } ;
105+ const jsonParametersResource = { getPath : ( ) => "fu.json" } ;
96106
97107 t . context . themeBuilderStub . returns ( [
98108 cssResource ,
@@ -110,15 +120,18 @@ test.serial("buildThemes (compress = false)", async (t) => {
110120 } ) ;
111121
112122 t . deepEqual ( t . context . themeBuilderStub . callCount , 1 ,
113- "Processor should be called once" ) ;
123+ "Theme Builder should be called once" ) ;
114124
115125 t . deepEqual ( t . context . themeBuilderStub . getCall ( 0 ) . args [ 0 ] , {
116126 resources : [ lessResource ] ,
117127 fs : { } ,
118128 options : {
129+ compressJSON : false ,
119130 compress : false
120131 }
121- } , "Processor should be called with expected arguments" ) ;
132+ } , "Theme Builder should be called with expected arguments" ) ;
133+
134+ t . deepEqual ( t . context . cssOptimizerStub . callCount , 0 , "CSS Optimizer should not be called" ) ;
122135
123136 t . deepEqual ( workspace . write . callCount , 3 ,
124137 "workspace.write should be called 3 times" ) ;
0 commit comments