@@ -16,6 +16,7 @@ import {
1616 typeInElement
1717} from 'ng-zorro-antd/core/testing' ;
1818import { NzTreeNode , NzTreeNodeOptions } from 'ng-zorro-antd/core/tree' ;
19+ import { NzStatus } from 'ng-zorro-antd/core/types' ;
1920
2021import { NzTreeSelectComponent } from './tree-select.component' ;
2122import { NzTreeSelectModule } from './tree-select.module' ;
@@ -33,7 +34,8 @@ describe('tree-select component', () => {
3334 NzTestTreeSelectBasicComponent ,
3435 NzTestTreeSelectCheckableComponent ,
3536 NzTestTreeSelectFormComponent ,
36- NzTestTreeSelectCustomizedIconComponent
37+ NzTestTreeSelectCustomizedIconComponent ,
38+ NzTestTreeSelectStatusComponent
3739 ] ,
3840 providers : [
3941 {
@@ -606,6 +608,29 @@ describe('tree-select component', () => {
606608 expect ( overlayContainerElement . querySelector ( 'i.anticon.anticon-frown-o' ) ) . toBeTruthy ( ) ;
607609 } ) ) ;
608610 } ) ;
611+
612+ describe ( 'Status' , ( ) => {
613+ let fixture : ComponentFixture < NzTestTreeSelectStatusComponent > ;
614+ let treeSelect : DebugElement ;
615+
616+ beforeEach ( ( ) => {
617+ fixture = TestBed . createComponent ( NzTestTreeSelectStatusComponent ) ;
618+ treeSelect = fixture . debugElement . query ( By . directive ( NzTreeSelectComponent ) ) ;
619+ } ) ;
620+
621+ it ( 'should className correct' , ( ) => {
622+ fixture . detectChanges ( ) ;
623+ expect ( treeSelect . nativeElement . className ) . toContain ( 'ant-select-status-error' ) ;
624+
625+ fixture . componentInstance . status = 'warning' ;
626+ fixture . detectChanges ( ) ;
627+ expect ( treeSelect . nativeElement . className ) . toContain ( 'ant-select-status-warning' ) ;
628+
629+ fixture . componentInstance . status = '' ;
630+ fixture . detectChanges ( ) ;
631+ expect ( treeSelect . nativeElement . className ) . not . toContain ( 'ant-select-status-warning' ) ;
632+ } ) ;
633+ } ) ;
609634} ) ;
610635
611636@Component ( {
@@ -863,3 +888,41 @@ export class NzTestTreeSelectCustomizedIconComponent {
863888 } )
864889 ] ;
865890}
891+
892+ @Component ( {
893+ template : `
894+ <nz-tree-select
895+ style="width:100%;margin:20px 0;"
896+ [nzNodes]="nodes"
897+ nzShowSearch
898+ [nzStatus]="status"
899+ nzPlaceHolder="Please select"
900+ [(ngModel)]="value"
901+ ></nz-tree-select>
902+ `
903+ } )
904+ export class NzTestTreeSelectStatusComponent {
905+ status : NzStatus = 'error' ;
906+ value ?: string = '1001' ;
907+ nodes = [
908+ {
909+ title : 'parent 1' ,
910+ key : '100' ,
911+ children : [
912+ {
913+ title : 'parent 1-0' ,
914+ key : '1001' ,
915+ children : [
916+ { title : 'leaf 1-0-0' , key : '10010' , isLeaf : true } ,
917+ { title : 'leaf 1-0-1' , key : '10011' , isLeaf : true }
918+ ]
919+ } ,
920+ {
921+ title : 'parent 1-1' ,
922+ key : '1002' ,
923+ children : [ { title : 'leaf 1-1-0' , key : '10020' , isLeaf : true } ]
924+ }
925+ ]
926+ }
927+ ] ;
928+ }
0 commit comments