@@ -278,62 +278,6 @@ describe('Browser Builder styles', () => {
278278 } ) ;
279279 } ) ;
280280
281- it ( 'inlines resources' , ( done ) => {
282- host . copyFile ( 'src/spectrum.png' , 'src/large.png' ) ;
283- host . writeMultipleFiles ( {
284- 'src/styles.scss' : `
285- h1 { background: url('./large.png'),
286- linear-gradient(to bottom, #0e40fa 25%, #0654f4 75%); }
287- h2 { background: url('./small.svg'); }
288- p { background: url(./small-id.svg#testID); }
289- ` ,
290- 'src/app/app.component.css' : `
291- h3 { background: url('../small.svg'); }
292- h4 { background: url("../large.png"); }
293- ` ,
294- 'src/small.svg' : imgSvg ,
295- 'src/small-id.svg' : imgSvg ,
296- } ) ;
297-
298- const overrides = {
299- aot : true ,
300- extractCss : true ,
301- styles : [ `src/styles.scss` ] ,
302- } ;
303-
304- runTargetSpec ( host , browserTargetSpec , overrides ) . pipe (
305- tap ( ( buildEvent ) => expect ( buildEvent . success ) . toBe ( true ) ) ,
306- tap ( ( ) => {
307- const fileName = 'dist/styles.css' ;
308- const content = virtualFs . fileBufferToString ( host . scopedSync ( ) . read ( normalize ( fileName ) ) ) ;
309- // Large image should not be inlined, and gradient should be there.
310- expect ( content ) . toMatch (
311- / u r l \( [ ' " ] ? l a r g e \. p n g [ ' " ] ? \) , \s + l i n e a r - g r a d i e n t \( t o b o t t o m , # 0 e 4 0 f a 2 5 % , # 0 6 5 4 f 4 7 5 % \) ; / ) ;
312- // Small image should be inlined.
313- expect ( content ) . toMatch ( / u r l \( \\ ? [ ' " ] d a t a : i m a g e \/ s v g \+ x m l / ) ;
314- // Small image with param should not be inlined.
315- expect ( content ) . toMatch ( / u r l \( [ ' " ] ? s m a l l - i d \. s v g # t e s t I D [ ' " ] ? \) / ) ;
316- } ) ,
317- tap ( ( ) => {
318- const fileName = 'dist/main.js' ;
319- const content = virtualFs . fileBufferToString ( host . scopedSync ( ) . read ( normalize ( fileName ) ) ) ;
320- // Large image should not be inlined.
321- expect ( content ) . toMatch ( / u r l \( (?: [ ' " ] | \\ ' ) ? l a r g e \. p n g (?: [ ' " ] | \\ ' ) ? \) / ) ;
322- // Small image should be inlined.
323- expect ( content ) . toMatch ( / u r l \( \\ ? [ ' " ] d a t a : i m a g e \/ s v g \+ x m l / ) ;
324- } ) ,
325- tap ( ( ) => {
326- expect ( host . scopedSync ( ) . exists ( normalize ( 'dist/small.svg' ) ) ) . toBe ( false ) ;
327- expect ( host . scopedSync ( ) . exists ( normalize ( 'dist/large.png' ) ) ) . toBe ( true ) ;
328- expect ( host . scopedSync ( ) . exists ( normalize ( 'dist/small-id.svg' ) ) ) . toBe ( true ) ;
329- } ) ,
330- // TODO: find a way to check logger/output for warnings.
331- // if (stdout.match(/postcss-url: \.+: Can't read file '\.+', ignoring/)) {
332- // throw new Error('Expected no postcss-url file read warnings.');
333- // }
334- ) . toPromise ( ) . then ( done , done . fail ) ;
335- } ) ;
336-
337281 it ( `supports font-awesome imports` , ( done ) => {
338282 host . writeMultipleFiles ( {
339283 'src/styles.scss' : `
@@ -407,8 +351,6 @@ describe('Browser Builder styles', () => {
407351 h3 { background: url('/assets/component-img-absolute.svg'); }
408352 h4 { background: url('../assets/component-img-relative.png'); }
409353 ` ,
410- // Use a small SVG for the absolute image to help validate that it is being referenced,
411- // because it is so small it would be inlined usually.
412354 'src/assets/global-img-absolute.svg' : imgSvg ,
413355 'src/assets/component-img-absolute.svg' : imgSvg ,
414356 } ) ;
@@ -427,12 +369,12 @@ describe('Browser Builder styles', () => {
427369 expect ( styles ) . toContain ( `url('global-img-relative.png')` ) ;
428370 expect ( main ) . toContain ( `url('/assets/component-img-absolute.svg')` ) ;
429371 expect ( main ) . toContain ( `url('component-img-relative.png')` ) ;
430- expect ( host . scopedSync ( ) . exists ( normalize ( 'dist/global-img-absolute.svg' ) ) )
431- . toBe ( false ) ;
372+ expect ( host . scopedSync ( ) . exists ( normalize ( 'dist/assets/ global-img-absolute.svg' ) ) )
373+ . toBe ( true ) ;
432374 expect ( host . scopedSync ( ) . exists ( normalize ( 'dist/global-img-relative.png' ) ) )
433375 . toBe ( true ) ;
434- expect ( host . scopedSync ( ) . exists ( normalize ( 'dist/component-img-absolute.svg' ) ) )
435- . toBe ( false ) ;
376+ expect ( host . scopedSync ( ) . exists ( normalize ( 'dist/assets/ component-img-absolute.svg' ) ) )
377+ . toBe ( true ) ;
436378 expect ( host . scopedSync ( ) . exists ( normalize ( 'dist/component-img-relative.png' ) ) )
437379 . toBe ( true ) ;
438380 } ) ,
0 commit comments