@@ -272,6 +272,47 @@ describe('metadataReader', () => {
272
272
}
273
273
} ) ;
274
274
275
+ it ( 'should pass url to Config.transformStyle when using styleUrls' , ( ) => {
276
+ let styleUrl = 'test.scss' ;
277
+ let invoked = false ;
278
+ const bak = Config . transformStyle ;
279
+
280
+ try {
281
+ Config . transformStyle = ( code , url ) => {
282
+ invoked = true ;
283
+ expect ( url ) . to . be . an ( 'string' ) ;
284
+ expect ( url ! . endsWith ( '.scss' ) ) . eq ( true ) ;
285
+ return { code } ;
286
+ } ;
287
+
288
+ const code = `
289
+ @Component({
290
+ selector: 'foo',
291
+ moduleId: module.id,
292
+ templateUrl: 'foo.html',
293
+ styleUrls: ['${ styleUrl } ']
294
+ })
295
+ class Bar {}
296
+ ` ;
297
+
298
+ const reader = new MetadataReader ( new FsFileResolver ( ) ) ;
299
+ const ast = getAst ( code , __dirname + '/../../test/fixtures/metadataReader/moduleid/foo.ts' ) ;
300
+ const classDeclaration = < ts . ClassDeclaration > last ( ast . statements ) ;
301
+ expect ( invoked ) . eq ( false ) ;
302
+ const metadata = reader . read ( classDeclaration ) ! ;
303
+ expect ( metadata instanceof ComponentMetadata ) . eq ( true ) ;
304
+ expect ( metadata . selector ) . eq ( 'foo' ) ;
305
+ const m = < ComponentMetadata > metadata ;
306
+ expect ( m . template ! . template . code . trim ( ) ) . eq ( '<div></div>' ) ;
307
+ expect ( m . template ! . url ! . endsWith ( 'foo.html' ) ) . eq ( true ) ;
308
+ expect ( m . styles ! [ 0 ] ! . style . code ) . eq ( '' ) ;
309
+ expect ( m . styles ! [ 0 ] ! . url ) . to . be . an ( 'string' ) ;
310
+ expect ( invoked ) . eq ( true ) ;
311
+ } finally {
312
+ Config . transformStyle = bak ;
313
+ }
314
+ } ) ;
315
+
275
316
it ( 'should work work with templates with "`"' , ( ) => {
276
317
const code = `
277
318
@Component({
0 commit comments