@@ -14,7 +14,12 @@ describe('alert', () => {
14
14
waitForAsync ( ( ) => {
15
15
TestBed . configureTestingModule ( {
16
16
imports : [ BidiModule , NzAlertModule , NoopAnimationsModule , NzIconTestModule ] ,
17
- declarations : [ NzDemoTestBasicComponent , NzDemoTestBannerComponent , NzTestAlertRtlComponent ]
17
+ declarations : [
18
+ NzDemoTestBasicComponent ,
19
+ NzDemoTestBannerComponent ,
20
+ NzTestAlertRtlComponent ,
21
+ NzTestAlertCustomIconComponent
22
+ ]
18
23
} ) ;
19
24
TestBed . compileComponents ( ) ;
20
25
} )
@@ -93,8 +98,10 @@ describe('alert', () => {
93
98
testComponent . showIcon = true ;
94
99
testComponent . iconType = 'lock' ;
95
100
fixture . detectChanges ( ) ;
96
- expect ( alert . nativeElement . querySelector ( '.ant-alert-icon' ) . classList ) . toContain ( 'anticon' ) ;
97
- expect ( alert . nativeElement . querySelector ( '.ant-alert-icon' ) . classList ) . toContain ( 'anticon-lock' ) ;
101
+ expect ( alert . nativeElement . querySelector ( '.ant-alert-icon' ) . firstElementChild . classList ) . toContain ( 'anticon' ) ;
102
+ expect ( alert . nativeElement . querySelector ( '.ant-alert-icon' ) . firstElementChild . classList ) . toContain (
103
+ 'anticon-lock'
104
+ ) ;
98
105
} ) ;
99
106
it ( 'should type work' , ( ) => {
100
107
const listOfType = [ 'success' , 'info' , 'warning' , 'error' ] ;
@@ -139,6 +146,15 @@ describe('alert', () => {
139
146
expect ( alert . nativeElement . firstElementChild ! . classList ) . not . toContain ( 'ant-alert-rtl' ) ;
140
147
} ) ;
141
148
} ) ;
149
+ describe ( 'custom icon' , ( ) => {
150
+ it ( 'should custom icon work' , ( ) => {
151
+ const fixture = TestBed . createComponent ( NzTestAlertCustomIconComponent ) ;
152
+ const alert = fixture . debugElement . query ( By . directive ( NzAlertComponent ) ) ;
153
+ fixture . detectChanges ( ) ;
154
+ expect ( alert . nativeElement . querySelector ( '.ant-alert-icon' ) ) . toBeDefined ( ) ;
155
+ expect ( alert . nativeElement . querySelector ( '.ant-alert-icon' ) . firstElementChild ) . not . toContain ( 'anticon' ) ;
156
+ } ) ;
157
+ } ) ;
142
158
} ) ;
143
159
144
160
@Component ( {
@@ -190,3 +206,20 @@ export class NzTestAlertRtlComponent {
190
206
@ViewChild ( Dir ) dir ! : Dir ;
191
207
direction = 'rtl' ;
192
208
}
209
+
210
+ @Component ( {
211
+ template : `
212
+ <nz-alert
213
+ nzType="success"
214
+ nzMessage="Success Tips"
215
+ nzDescription="Detailed description and advices about successful copywriting."
216
+ [nzIcon]="customIconTemplate"
217
+ nzShowIcon
218
+ ></nz-alert>
219
+
220
+ <ng-template #customIconTemplate>
221
+ <div> S </div>
222
+ </ng-template>
223
+ `
224
+ } )
225
+ export class NzTestAlertCustomIconComponent { }
0 commit comments