Skip to content

Commit

Permalink
chore: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
wenqi73 committed Oct 13, 2018
1 parent 4f793df commit a08e149
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
7 changes: 3 additions & 4 deletions components/tree-select/demo/customized-icon.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { NzTreeNode } from 'ng-zorro-antd';
import { Component } from '@angular/core';

@Component({
selector: 'nz-demo-tree-select-customized-icon',
Expand Down Expand Up @@ -28,7 +27,7 @@ import { NzTreeNode } from 'ng-zorro-antd';
export class NzDemoTreeSelectCustomizedIconComponent {
value: string;
nodes = [
new NzTreeNode({
{
title : 'root1',
key : '1001',
expanded: true,
Expand Down Expand Up @@ -64,6 +63,6 @@ export class NzDemoTreeSelectCustomizedIconComponent {
]
}
]
})
}
];
}
59 changes: 58 additions & 1 deletion components/tree-select/nz-tree-select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('tree-select component', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports : [ NzTreeSelectModule, NoopAnimationsModule, FormsModule, ReactiveFormsModule ],
declarations: [ NzTestTreeSelectBasicComponent, NzTestTreeSelectCheckableComponent, NzTestTreeSelectFormComponent ]
declarations: [ NzTestTreeSelectBasicComponent, NzTestTreeSelectCheckableComponent, NzTestTreeSelectFormComponent, NzTestTreeSelectCustomizedIconComponent ]
});
TestBed.compileComponents();
inject([ OverlayContainer ], (oc: OverlayContainer) => {
Expand Down Expand Up @@ -340,6 +340,28 @@ describe('tree-select component', () => {
}));
});

describe('customized icon', () => {
let fixture;
let testComponent;
let treeSelect;
let treeSelectComponent;
beforeEach(() => {
fixture = TestBed.createComponent(NzTestTreeSelectCustomizedIconComponent);
testComponent = fixture.debugElement.componentInstance;
treeSelect = fixture.debugElement.query(By.directive(NzTreeSelectComponent));
treeSelectComponent = treeSelect.componentInstance;
});
it('should display', fakeAsync(() => {
// ExpressionChangedAfterItHasBeenCheckedError
treeSelectComponent.ngAfterViewInit();
fixture.detectChanges();
treeSelect.nativeElement.click();
fixture.detectChanges();
flush();
expect(overlayContainerElement.querySelector('i.anticon.anticon-frown-o')).toBeTruthy();
}));
});

});

@Component({
Expand Down Expand Up @@ -563,3 +585,38 @@ export class NzTestTreeSelectFormComponent {
this.formGroup.get('select').reset(null);
}
}

@Component({
selector: 'nz-test-tree-select-customized-icon',
template: `
<nz-tree-select
[nzNodes]="nodes"
[(ngModel)]="value"
>
<ng-template #nzTreeTemplate let-node>
<span>
<i class="anticon anticon-frown-o"></i> {{node.title}}
</span>
</ng-template>
</nz-tree-select>
`
})
export class NzTestTreeSelectCustomizedIconComponent {
value: string;
nodes = [
new NzTreeNode({
title : 'root3',
key : '1003',
children: [
{
title: 'child3.1',
key : '10031'
},
{
title: 'child3.2',
key : '10032'
}
]
})
];
}

0 comments on commit a08e149

Please sign in to comment.