diff --git a/components/tree-select/tree-select.component.ts b/components/tree-select/tree-select.component.ts
index 0c698b4ef8f..8cfd3b795d1 100644
--- a/components/tree-select/tree-select.component.ts
+++ b/components/tree-select/tree-select.component.ts
@@ -176,7 +176,7 @@ const TREE_SELECT_DEFAULT_CLASS = 'ant-select-dropdown ant-select-tree-dropdown'
-
+
`,
providers: [
diff --git a/components/tree-select/tree-select.spec.ts b/components/tree-select/tree-select.spec.ts
index 63a81a4755c..e0452993c8c 100644
--- a/components/tree-select/tree-select.spec.ts
+++ b/components/tree-select/tree-select.spec.ts
@@ -76,10 +76,18 @@ describe('tree-select component', () => {
expect(treeSelect.nativeElement.classList).toContain('ant-select-lg');
}));
it('should allowClear work', () => {
- expect(treeSelect.nativeElement.classList).not.toContain('ant-select-allow-clear');
+ const nativeElement = treeSelect.nativeElement as HTMLElement;
+ expect(nativeElement.classList).not.toContain('ant-select-allow-clear');
+ expect(nativeElement.querySelector('nz-select-clear')).toBeNull();
testComponent.allowClear = true;
fixture.detectChanges();
- expect(treeSelect.nativeElement.classList).toContain('ant-select-allow-clear');
+ expect(nativeElement.classList).toContain('ant-select-allow-clear');
+ expect(nativeElement.querySelector('nz-select-clear')).not.toBeNull();
+
+ (nativeElement.querySelector('nz-select-clear') as HTMLElement)!.click();
+ fixture.detectChanges();
+
+ expect(nativeElement.querySelector('nz-select-clear')).toBeNull();
});
it('should click toggle open', () => {
treeSelect.nativeElement.click();
@@ -451,12 +459,15 @@ describe('tree-select component', () => {
fixture.detectChanges();
flush();
fixture.detectChanges();
- expect(treeSelect.nativeElement.classList).not.toContain('ant-select-disabled');
+ const nativeElement = treeSelect.nativeElement as HTMLElement;
+ expect(nativeElement.classList).not.toContain('ant-select-disabled');
+ expect(nativeElement.querySelector('nz-select-clear')).not.toBeNull();
testComponent.disable();
fixture.detectChanges();
flush();
fixture.detectChanges();
- expect(treeSelect.nativeElement.classList).toContain('ant-select-disabled');
+ expect(nativeElement.classList).toContain('ant-select-disabled');
+ expect(nativeElement.querySelector('nz-select-clear')).toBeNull();
}));
it('should set null value work', fakeAsync(() => {