@@ -358,10 +358,10 @@ describe('MatIcon', () => {
358
358
iconRegistry . registerFontClassAlias ( 'f1' , 'font1' ) ;
359
359
iconRegistry . registerFontClassAlias ( 'f2' ) ;
360
360
361
- let fixture = TestBed . createComponent ( IconWithCustomFontCss ) ;
362
-
361
+ const fixture = TestBed . createComponent ( IconWithCustomFontCss ) ;
363
362
const testComponent = fixture . componentInstance ;
364
363
const matIconElement = fixture . debugElement . nativeElement . querySelector ( 'mat-icon' ) ;
364
+
365
365
testComponent . fontSet = 'f1' ;
366
366
testComponent . fontIcon = 'house' ;
367
367
fixture . detectChanges ( ) ;
@@ -377,6 +377,45 @@ describe('MatIcon', () => {
377
377
fixture . detectChanges ( ) ;
378
378
expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'f3' , 'mat-icon' , 'tent' ] ) ;
379
379
} ) ;
380
+
381
+ it ( 'should handle values with extraneous spaces being passed in to `fontSet`' , ( ) => {
382
+ const fixture = TestBed . createComponent ( IconWithCustomFontCss ) ;
383
+ const matIconElement = fixture . debugElement . nativeElement . querySelector ( 'mat-icon' ) ;
384
+
385
+ expect ( ( ) => {
386
+ fixture . componentInstance . fontSet = 'font set' ;
387
+ fixture . detectChanges ( ) ;
388
+ } ) . not . toThrow ( ) ;
389
+
390
+ expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'font' , 'mat-icon' ] ) ;
391
+
392
+ expect ( ( ) => {
393
+ fixture . componentInstance . fontSet = ' changed' ;
394
+ fixture . detectChanges ( ) ;
395
+ } ) . not . toThrow ( ) ;
396
+
397
+ expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'changed' , 'mat-icon' ] ) ;
398
+ } ) ;
399
+
400
+ it ( 'should handle values with extraneous spaces being passed in to `fontIcon`' , ( ) => {
401
+ const fixture = TestBed . createComponent ( IconWithCustomFontCss ) ;
402
+ const matIconElement = fixture . debugElement . nativeElement . querySelector ( 'mat-icon' ) ;
403
+
404
+ expect ( ( ) => {
405
+ fixture . componentInstance . fontIcon = 'font icon' ;
406
+ fixture . detectChanges ( ) ;
407
+ } ) . not . toThrow ( ) ;
408
+
409
+ expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'font' , 'mat-icon' , 'material-icons' ] ) ;
410
+
411
+ expect ( ( ) => {
412
+ fixture . componentInstance . fontIcon = ' changed' ;
413
+ fixture . detectChanges ( ) ;
414
+ } ) . not . toThrow ( ) ;
415
+
416
+ expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'changed' , 'mat-icon' , 'material-icons' ] ) ;
417
+ } ) ;
418
+
380
419
} ) ;
381
420
382
421
/** Marks an svg icon url as explicitly trusted. */
0 commit comments