@@ -87,6 +87,19 @@ describe('MatIcon', () => {
8787 expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'mat-icon' , 'mat-primary' , 'material-icons' ] ) ;
8888 } ) ;
8989
90+ it ( 'should apply a class if there is no color' , ( ) => {
91+ let fixture = TestBed . createComponent ( IconWithColor ) ;
92+
93+ const testComponent = fixture . componentInstance ;
94+ const matIconElement = fixture . debugElement . nativeElement . querySelector ( 'mat-icon' ) ;
95+ testComponent . iconName = 'home' ;
96+ testComponent . iconColor = '' ;
97+ fixture . detectChanges ( ) ;
98+
99+ expect ( sortedClassNames ( matIconElement ) )
100+ . toEqual ( [ 'mat-icon' , 'mat-icon-no-color' , 'material-icons' ] ) ;
101+ } ) ;
102+
90103 it ( 'should mark mat-icon as aria-hidden by default' , ( ) => {
91104 const fixture = TestBed . createComponent ( IconWithLigature ) ;
92105 const iconElement = fixture . debugElement . nativeElement . querySelector ( 'mat-icon' ) ;
@@ -121,7 +134,8 @@ describe('MatIcon', () => {
121134 const matIconElement = fixture . debugElement . nativeElement . querySelector ( 'mat-icon' ) ;
122135 testComponent . iconName = 'home' ;
123136 fixture . detectChanges ( ) ;
124- expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'mat-icon' , 'material-icons' ] ) ;
137+ expect ( sortedClassNames ( matIconElement ) )
138+ . toEqual ( [ 'mat-icon' , 'mat-icon-no-color' , 'material-icons' ] ) ;
125139 } ) ;
126140
127141 it ( 'should use alternate icon font if set' , ( ) => {
@@ -133,7 +147,7 @@ describe('MatIcon', () => {
133147 const matIconElement = fixture . debugElement . nativeElement . querySelector ( 'mat-icon' ) ;
134148 testComponent . iconName = 'home' ;
135149 fixture . detectChanges ( ) ;
136- expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'mat-icon' , 'myfont' ] ) ;
150+ expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'mat-icon' , 'mat-icon-no-color' , ' myfont'] ) ;
137151 } ) ;
138152 } ) ;
139153
@@ -682,17 +696,20 @@ describe('MatIcon', () => {
682696 testComponent . fontSet = 'f1' ;
683697 testComponent . fontIcon = 'house' ;
684698 fixture . detectChanges ( ) ;
685- expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'font1' , 'house' , 'mat-icon' ] ) ;
699+ expect ( sortedClassNames ( matIconElement ) )
700+ . toEqual ( [ 'font1' , 'house' , 'mat-icon' , 'mat-icon-no-color' ] ) ;
686701
687702 testComponent . fontSet = 'f2' ;
688703 testComponent . fontIcon = 'igloo' ;
689704 fixture . detectChanges ( ) ;
690- expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'f2' , 'igloo' , 'mat-icon' ] ) ;
705+ expect ( sortedClassNames ( matIconElement ) )
706+ . toEqual ( [ 'f2' , 'igloo' , 'mat-icon' , 'mat-icon-no-color' ] ) ;
691707
692708 testComponent . fontSet = 'f3' ;
693709 testComponent . fontIcon = 'tent' ;
694710 fixture . detectChanges ( ) ;
695- expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'f3' , 'mat-icon' , 'tent' ] ) ;
711+ expect ( sortedClassNames ( matIconElement ) )
712+ . toEqual ( [ 'f3' , 'mat-icon' , 'mat-icon-no-color' , 'tent' ] ) ;
696713 } ) ;
697714
698715 it ( 'should handle values with extraneous spaces being passed in to `fontSet`' , ( ) => {
@@ -704,14 +721,15 @@ describe('MatIcon', () => {
704721 fixture . detectChanges ( ) ;
705722 } ) . not . toThrow ( ) ;
706723
707- expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'font' , 'mat-icon' ] ) ;
724+ expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'font' , 'mat-icon' , 'mat-icon-no-color' ] ) ;
708725
709726 expect ( ( ) => {
710727 fixture . componentInstance . fontSet = ' changed' ;
711728 fixture . detectChanges ( ) ;
712729 } ) . not . toThrow ( ) ;
713730
714- expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'changed' , 'mat-icon' ] ) ;
731+ expect ( sortedClassNames ( matIconElement ) )
732+ . toEqual ( [ 'changed' , 'mat-icon' , 'mat-icon-no-color' ] ) ;
715733 } ) ;
716734
717735 it ( 'should handle values with extraneous spaces being passed in to `fontIcon`' , ( ) => {
@@ -723,14 +741,16 @@ describe('MatIcon', () => {
723741 fixture . detectChanges ( ) ;
724742 } ) . not . toThrow ( ) ;
725743
726- expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'font' , 'mat-icon' , 'material-icons' ] ) ;
744+ expect ( sortedClassNames ( matIconElement ) )
745+ . toEqual ( [ 'font' , 'mat-icon' , 'mat-icon-no-color' , 'material-icons' ] ) ;
727746
728747 expect ( ( ) => {
729748 fixture . componentInstance . fontIcon = ' changed' ;
730749 fixture . detectChanges ( ) ;
731750 } ) . not . toThrow ( ) ;
732751
733- expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'changed' , 'mat-icon' , 'material-icons' ] ) ;
752+ expect ( sortedClassNames ( matIconElement ) )
753+ . toEqual ( [ 'changed' , 'mat-icon' , 'mat-icon-no-color' , 'material-icons' ] ) ;
734754 } ) ;
735755
736756 } ) ;
0 commit comments