@@ -87,6 +87,19 @@ describe('MatIcon', () => {
87
87
expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'mat-icon' , 'mat-primary' , 'material-icons' ] ) ;
88
88
} ) ;
89
89
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
+
90
103
it ( 'should mark mat-icon as aria-hidden by default' , ( ) => {
91
104
const fixture = TestBed . createComponent ( IconWithLigature ) ;
92
105
const iconElement = fixture . debugElement . nativeElement . querySelector ( 'mat-icon' ) ;
@@ -121,7 +134,8 @@ describe('MatIcon', () => {
121
134
const matIconElement = fixture . debugElement . nativeElement . querySelector ( 'mat-icon' ) ;
122
135
testComponent . iconName = 'home' ;
123
136
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' ] ) ;
125
139
} ) ;
126
140
127
141
it ( 'should use alternate icon font if set' , ( ) => {
@@ -133,7 +147,7 @@ describe('MatIcon', () => {
133
147
const matIconElement = fixture . debugElement . nativeElement . querySelector ( 'mat-icon' ) ;
134
148
testComponent . iconName = 'home' ;
135
149
fixture . detectChanges ( ) ;
136
- expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'mat-icon' , 'myfont' ] ) ;
150
+ expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'mat-icon' , 'mat-icon-no-color' , ' myfont'] ) ;
137
151
} ) ;
138
152
} ) ;
139
153
@@ -682,17 +696,20 @@ describe('MatIcon', () => {
682
696
testComponent . fontSet = 'f1' ;
683
697
testComponent . fontIcon = 'house' ;
684
698
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' ] ) ;
686
701
687
702
testComponent . fontSet = 'f2' ;
688
703
testComponent . fontIcon = 'igloo' ;
689
704
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' ] ) ;
691
707
692
708
testComponent . fontSet = 'f3' ;
693
709
testComponent . fontIcon = 'tent' ;
694
710
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' ] ) ;
696
713
} ) ;
697
714
698
715
it ( 'should handle values with extraneous spaces being passed in to `fontSet`' , ( ) => {
@@ -704,14 +721,15 @@ describe('MatIcon', () => {
704
721
fixture . detectChanges ( ) ;
705
722
} ) . not . toThrow ( ) ;
706
723
707
- expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'font' , 'mat-icon' ] ) ;
724
+ expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'font' , 'mat-icon' , 'mat-icon-no-color' ] ) ;
708
725
709
726
expect ( ( ) => {
710
727
fixture . componentInstance . fontSet = ' changed' ;
711
728
fixture . detectChanges ( ) ;
712
729
} ) . not . toThrow ( ) ;
713
730
714
- expect ( sortedClassNames ( matIconElement ) ) . toEqual ( [ 'changed' , 'mat-icon' ] ) ;
731
+ expect ( sortedClassNames ( matIconElement ) )
732
+ . toEqual ( [ 'changed' , 'mat-icon' , 'mat-icon-no-color' ] ) ;
715
733
} ) ;
716
734
717
735
it ( 'should handle values with extraneous spaces being passed in to `fontIcon`' , ( ) => {
@@ -723,14 +741,16 @@ describe('MatIcon', () => {
723
741
fixture . detectChanges ( ) ;
724
742
} ) . not . toThrow ( ) ;
725
743
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' ] ) ;
727
746
728
747
expect ( ( ) => {
729
748
fixture . componentInstance . fontIcon = ' changed' ;
730
749
fixture . detectChanges ( ) ;
731
750
} ) . not . toThrow ( ) ;
732
751
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' ] ) ;
734
754
} ) ;
735
755
736
756
} ) ;
0 commit comments