33 * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
44 */
55
6- import { BidiModule , Dir , Direction } from '@angular/cdk/bidi' ;
7- import { Component , DebugElement , ViewChild } from '@angular/core' ;
6+ import { BidiModule , Direction } from '@angular/cdk/bidi' ;
7+ import { Component , DebugElement } from '@angular/core' ;
88import { ComponentFixture , fakeAsync , TestBed , tick } from '@angular/core/testing' ;
99import { By } from '@angular/platform-browser' ;
1010import { provideAnimationsAsync } from '@angular/platform-browser/animations/async' ;
1111
12- import { badgePresetColors } from 'ng-zorro-antd/badge/preset-colors' ;
13- import { NzRibbonComponent } from 'ng-zorro-antd/badge/ribbon.component' ;
1412import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation' ;
1513import { NgStyleInterface , NzSizeDSType } from 'ng-zorro-antd/core/types' ;
1614
1715import { NzBadgeComponent } from './badge.component' ;
1816import { NzBadgeModule } from './badge.module' ;
17+ import { badgePresetColors } from './preset-colors' ;
18+ import { NzRibbonComponent } from './ribbon.component' ;
19+ import { NzBadgeStatusType } from './types' ;
1920
2021describe ( 'nz-badge' , ( ) => {
2122 beforeEach ( ( ) => {
@@ -242,8 +243,22 @@ describe('nz-badge', () => {
242243 expect ( badgeElement . nativeElement . querySelector ( '.ant-badge-status-text' ) ) . toBeNull ( ) ;
243244 } ) ) ;
244245
246+ it ( 'should hex nzColor work' , ( ) => {
247+ testComponent . count = 0 ;
248+ testComponent . color = '#f5222d' ;
249+ fixture . detectChanges ( ) ;
250+ expect ( badgeElement . nativeElement . querySelector ( '.ant-badge-status-dot' ) . style . backgroundColor ) . toBe (
251+ 'rgb(245, 34, 45)'
252+ ) ;
253+
254+ testComponent . count = 5 ;
255+ fixture . detectChanges ( ) ;
256+ expect ( badgeElement . nativeElement . querySelector ( 'nz-badge-sup' ) . style . backgroundColor ) . toBe ( 'rgb(245, 34, 45)' ) ;
257+ } ) ;
258+
245259 it ( 'should nzStyle work even if nzColor is not provided' , ( ) => {
246260 testComponent . color = undefined ;
261+ testComponent . status = 'success' ; // must set nzStatus to make sure status dot is rendered
247262 testComponent . style = { backgroundColor : '#52c41a' } ;
248263 fixture . detectChanges ( ) ;
249264 expect ( badgeElement . nativeElement . querySelector ( 'nz-badge-sup' ) . style . backgroundColor ) . toBe ( 'rgb(82, 196, 26)' ) ;
@@ -345,7 +360,7 @@ export class NzTestBadgeBasicComponent {
345360 standalone = false ;
346361 overflow = 20 ;
347362 showZero = false ;
348- status ! : string ;
363+ status ! : NzBadgeStatusType | string ;
349364 style ! : NgStyleInterface ;
350365 text ! : string ;
351366 title ?: string | null ;
@@ -364,7 +379,6 @@ export class NzTestBadgeBasicComponent {
364379 `
365380} )
366381export class NzTestBadgeRtlComponent {
367- @ViewChild ( Dir ) dir ! : Dir ;
368382 direction : Direction = 'rtl' ;
369383 count = 5 ;
370384}
0 commit comments