@@ -118,13 +118,7 @@ test.serial("determineResourceDetails: properties", async (t) => {
118
118
} ) ;
119
119
120
120
test . serial ( "determineResourceDetails: view.xml" , async ( t ) => {
121
- const resourceCollector = new ResourceCollector ( {
122
- getModuleInfo : async ( moduleInfo ) => {
123
- return {
124
- name : "myName"
125
- } ;
126
- }
127
- } ) ;
121
+ const resourceCollector = new ResourceCollector ( ) ;
128
122
const enrichWithDependencyInfoStub = sinon . stub ( resourceCollector , "enrichWithDependencyInfo" )
129
123
. returns ( Promise . resolve ( ) ) ;
130
124
await resourceCollector . visitResource ( { getPath : ( ) => "/resources/mylib/my.view.xml" , getSize : async ( ) => 13 } ) ;
@@ -133,6 +127,72 @@ test.serial("determineResourceDetails: view.xml", async (t) => {
133
127
t . is ( enrichWithDependencyInfoStub . getCall ( 0 ) . args [ 0 ] . name , "mylib/my.view.xml" , "is called with view" ) ;
134
128
} ) ;
135
129
130
+ test . serial ( "determineResourceDetails: Debug bundle" , async ( t ) => {
131
+ const resourceCollector = new ResourceCollector ( ) ;
132
+
133
+ const enrichWithDependencyInfoStub = sinon . stub ( resourceCollector , "enrichWithDependencyInfo" ) . resolves ( ) ;
134
+ await resourceCollector . visitResource ( { getPath : ( ) => "/resources/MyBundle-dbg.js" , getSize : async ( ) => 13 } ) ;
135
+
136
+ await resourceCollector . determineResourceDetails ( {
137
+ debugBundles : [ "MyBundle-dbg.js" ]
138
+ } ) ;
139
+ t . is ( enrichWithDependencyInfoStub . callCount , 1 , "enrichWithDependencyInfo is called once" ) ;
140
+ t . is ( enrichWithDependencyInfoStub . getCall ( 0 ) . args [ 0 ] . name , "MyBundle-dbg.js" ,
141
+ "enrichWithDependencyInfo is called with debug bundle" ) ;
142
+ } ) ;
143
+
144
+ test . serial ( "determineResourceDetails: Debug files and non-debug files" , async ( t ) => {
145
+ const resourceCollector = new ResourceCollector ( ) ;
146
+
147
+ const enrichWithDependencyInfoStub = sinon . stub ( resourceCollector , "enrichWithDependencyInfo" )
148
+ . callsFake ( ( resourceInfo ) => {
149
+ // Simulate enriching resource info with dependency info to test whether it gets shared
150
+ // with the dbg resource alter on
151
+ resourceInfo . dynRequired = true ;
152
+ } ) ;
153
+ await Promise . all ( [
154
+ "/resources/MyBundle-dbg.js" ,
155
+ "/resources/mylib/MyControlA-dbg.js" ,
156
+ "/resources/mylib/MyControlA.js" ,
157
+ "/resources/mylib/MyControlB.js" ,
158
+ "/resources/mylib/MyControlB-dbg.js"
159
+ ] . map ( ( resourcePath ) => {
160
+ return resourceCollector . visitResource ( { getPath : ( ) => resourcePath , getSize : async ( ) => 13 } ) ;
161
+ } ) ) ;
162
+
163
+ await resourceCollector . determineResourceDetails ( {
164
+ debugResources : [ "**/*-dbg.js" ] ,
165
+ debugBundles : [ "MyBundle-dbg.js" ]
166
+ } ) ;
167
+ t . is ( enrichWithDependencyInfoStub . callCount , 3 , "enrichWithDependencyInfo is called three times" ) ;
168
+ t . is ( enrichWithDependencyInfoStub . getCall ( 0 ) . args [ 0 ] . name , "MyBundle-dbg.js" ,
169
+ "enrichWithDependencyInfo called with debug bundle" ) ;
170
+ t . is ( enrichWithDependencyInfoStub . getCall ( 1 ) . args [ 0 ] . name , "mylib/MyControlA.js" ,
171
+ "enrichWithDependencyInfo called with non-debug control A" ) ;
172
+ t . is ( enrichWithDependencyInfoStub . getCall ( 2 ) . args [ 0 ] . name , "mylib/MyControlB.js" ,
173
+ "enrichWithDependencyInfo called with non-debug control B" ) ;
174
+
175
+ t . is ( resourceCollector . _resources . get ( "MyBundle-dbg.js" ) . isDebug , true , "MyBundle-dbg is a debug file" ) ;
176
+ t . is ( resourceCollector . _resources . get ( "MyBundle-dbg.js" ) . dynRequired , true ,
177
+ "MyBundle-dbg is flagged as dynRequired" ) ;
178
+
179
+ t . is ( resourceCollector . _resources . get ( "mylib/MyControlA.js" ) . isDebug , false , "MyControlA is no debug file" ) ;
180
+ t . is ( resourceCollector . _resources . get ( "mylib/MyControlA.js" ) . dynRequired , true ,
181
+ "MyControlA is flagged as dynRequired" ) ;
182
+
183
+ t . is ( resourceCollector . _resources . get ( "mylib/MyControlA-dbg.js" ) . isDebug , true , "MyControlA-dbg is a debug file" ) ;
184
+ t . is ( resourceCollector . _resources . get ( "mylib/MyControlA-dbg.js" ) . dynRequired , true ,
185
+ "MyControlA-dbg is flagged as dynRequired" ) ;
186
+
187
+ t . is ( resourceCollector . _resources . get ( "mylib/MyControlB.js" ) . isDebug , false , "MyControlB is no debug file" ) ;
188
+ t . is ( resourceCollector . _resources . get ( "mylib/MyControlB.js" ) . dynRequired , true ,
189
+ "MyControlB is flagged as dynRequired" ) ;
190
+
191
+ t . is ( resourceCollector . _resources . get ( "mylib/MyControlB-dbg.js" ) . isDebug , true , "MyControlB-dbg is a debug file" ) ;
192
+ t . is ( resourceCollector . _resources . get ( "mylib/MyControlB-dbg.js" ) . dynRequired , true ,
193
+ "MyControlB-dbg is flagged as dynRequired" ) ;
194
+ } ) ;
195
+
136
196
test . serial ( "enrichWithDependencyInfo: add infos to resourceinfo" , async ( t ) => {
137
197
const resourceCollector = new ResourceCollector ( {
138
198
getModuleInfo : async ( ) => {
0 commit comments