@@ -358,10 +358,10 @@ describe('MatIcon', () => {
358358 iconRegistry . registerFontClassAlias ( 'f1' , 'font1' ) ;
359359 iconRegistry . registerFontClassAlias ( 'f2' ) ;
360360
361- let fixture = TestBed . createComponent ( IconWithCustomFontCss ) ;
362-
361+ const fixture = TestBed . createComponent ( IconWithCustomFontCss ) ;
363362 const testComponent = fixture . componentInstance ;
364363 const matIconElement = fixture . debugElement . nativeElement . querySelector ( 'mat-icon' ) ;
364+
365365 testComponent . fontSet = 'f1' ;
366366 testComponent . fontIcon = 'house' ;
367367 fixture . detectChanges ( ) ;
@@ -377,6 +377,45 @@ describe('MatIcon', () => {
377377 fixture . detectChanges ( ) ;
378378 expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'f3' , 'mat-icon' , 'tent' ] ) ;
379379 } ) ;
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+
380419 } ) ;
381420
382421 /** Marks an svg icon url as explicitly trusted. */
0 commit comments