@@ -8,9 +8,11 @@ let buildThemes = require("../../../lib/tasks/buildThemes");
8
8
test . beforeEach ( ( t ) => {
9
9
// Stubbing processors/themeBuilder
10
10
t . context . themeBuilderStub = sinon . stub ( ) ;
11
+ t . context . cssOptimizerStub = sinon . stub ( ) ;
11
12
t . context . fsInterfaceStub = sinon . stub ( require ( "@ui5/fs" ) , "fsInterface" ) ;
12
13
t . context . fsInterfaceStub . returns ( { } ) ;
13
14
mock ( "../../../lib/processors/themeBuilder" , t . context . themeBuilderStub ) ;
15
+ mock ( "../../../lib/processors/cssOptimizer" , t . context . cssOptimizerStub ) ;
14
16
15
17
// Re-require tested module
16
18
buildThemes = mock . reRequire ( "../../../lib/tasks/buildThemes" ) ;
@@ -19,10 +21,11 @@ test.beforeEach((t) => {
19
21
test . afterEach . always ( ( t ) => {
20
22
t . context . fsInterfaceStub . restore ( ) ;
21
23
mock . stop ( "../../../lib/processors/themeBuilder" ) ;
24
+ mock . stop ( "../../../lib/processors/cssOptimizer" ) ;
22
25
} ) ;
23
26
24
27
test . serial ( "buildThemes" , async ( t ) => {
25
- t . plan ( 6 ) ;
28
+ t . plan ( 8 ) ;
26
29
27
30
const lessResource = { } ;
28
31
@@ -37,9 +40,9 @@ test.serial("buildThemes", async (t) => {
37
40
write : sinon . stub ( )
38
41
} ;
39
42
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" } ;
43
46
44
47
t . context . themeBuilderStub . returns ( [
45
48
cssResource ,
@@ -56,15 +59,22 @@ test.serial("buildThemes", async (t) => {
56
59
} ) ;
57
60
58
61
t . deepEqual ( t . context . themeBuilderStub . callCount , 1 ,
59
- "Processor should be called once" ) ;
62
+ "Theme Builder should be called once" ) ;
60
63
61
64
t . deepEqual ( t . context . themeBuilderStub . getCall ( 0 ) . args [ 0 ] , {
62
65
resources : [ lessResource ] ,
63
66
fs : { } ,
64
67
options : {
65
- compress : true // default
68
+ compressJSON : true , // default
69
+ compress : false
66
70
}
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" ) ;
68
78
69
79
t . deepEqual ( workspace . write . callCount , 3 ,
70
80
"workspace.write should be called 3 times" ) ;
@@ -75,7 +85,7 @@ test.serial("buildThemes", async (t) => {
75
85
76
86
77
87
test . serial ( "buildThemes (compress = false)" , async ( t ) => {
78
- t . plan ( 6 ) ;
88
+ t . plan ( 7 ) ;
79
89
80
90
const lessResource = { } ;
81
91
@@ -90,9 +100,9 @@ test.serial("buildThemes (compress = false)", async (t) => {
90
100
write : sinon . stub ( )
91
101
} ;
92
102
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" } ;
96
106
97
107
t . context . themeBuilderStub . returns ( [
98
108
cssResource ,
@@ -110,15 +120,18 @@ test.serial("buildThemes (compress = false)", async (t) => {
110
120
} ) ;
111
121
112
122
t . deepEqual ( t . context . themeBuilderStub . callCount , 1 ,
113
- "Processor should be called once" ) ;
123
+ "Theme Builder should be called once" ) ;
114
124
115
125
t . deepEqual ( t . context . themeBuilderStub . getCall ( 0 ) . args [ 0 ] , {
116
126
resources : [ lessResource ] ,
117
127
fs : { } ,
118
128
options : {
129
+ compressJSON : false ,
119
130
compress : false
120
131
}
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" ) ;
122
135
123
136
t . deepEqual ( workspace . write . callCount , 3 ,
124
137
"workspace.write should be called 3 times" ) ;
0 commit comments