Skip to content

Commit

Permalink
fix(module:tree-select): fix tree-select overlay's index probelem NG-…
Browse files Browse the repository at this point in the history
  • Loading branch information
100cm committed Jan 11, 2019
1 parent 6ee20c7 commit 6c63673
Showing 1 changed file with 58 additions and 75 deletions.
133 changes: 58 additions & 75 deletions components/tree-select/nz-tree-select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ describe('tree-select component', () => {
let overlayContainerElement: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [NzTreeSelectModule, NoopAnimationsModule, FormsModule, ReactiveFormsModule],
declarations: [NzTestTreeSelectBasicComponent, NzTestTreeSelectCheckableComponent, NzTestTreeSelectFormComponent]
imports : [ NzTreeSelectModule, NoopAnimationsModule, FormsModule, ReactiveFormsModule ],
declarations: [ NzTestTreeSelectBasicComponent, NzTestTreeSelectCheckableComponent, NzTestTreeSelectFormComponent ]
});
TestBed.compileComponents();
inject([OverlayContainer], (oc: OverlayContainer) => {
inject([ OverlayContainer ], (oc: OverlayContainer) => {
overlayContainer = oc;
overlayContainerElement = oc.getContainerElement();
})();
}));
afterEach(inject([OverlayContainer], (currentOverlayContainer: OverlayContainer) => {
afterEach(inject([ OverlayContainer ], (currentOverlayContainer: OverlayContainer) => {
currentOverlayContainer.ngOnDestroy();
overlayContainer.ngOnDestroy();
}));
Expand Down Expand Up @@ -118,23 +118,6 @@ describe('tree-select component', () => {
expect(treeSelectComponent.nzOpen).toBe(true);
expect(overlayPane.style.minWidth).toBe('250px');
}));
it('should dropdownMatchSelectWidth work', fakeAsync(() => {
testComponent.dropdownMatchSelectWidth = true;
fixture.detectChanges();
treeSelect.nativeElement.click();
fixture.detectChanges();
expect(treeSelectComponent.nzOpen).toBe(true);
const overlayPane = overlayContainerElement.querySelector('.cdk-overlay-pane') as HTMLElement;
expect(overlayPane.style.width).toBe('250px');
treeSelectComponent.closeDropDown();
fixture.detectChanges();
testComponent.dropdownMatchSelectWidth = false;
fixture.detectChanges();
treeSelect.nativeElement.click();
fixture.detectChanges();
expect(treeSelectComponent.nzOpen).toBe(true);
expect(overlayPane.style.minWidth).toBe('250px');
}));
it('should clear value work', fakeAsync(() => {
testComponent.allowClear = true;
fixture.detectChanges();
Expand Down Expand Up @@ -175,7 +158,7 @@ describe('tree-select component', () => {
fixture.detectChanges();
expect(treeSelectComponent.nzOpen).toBe(true);
fixture.detectChanges();
const targetNode = overlayContainerElement.querySelectorAll('nz-tree-node')[2];
const targetNode = overlayContainerElement.querySelectorAll('nz-tree-node')[ 2 ];
dispatchMouseEvent(targetNode, 'click');
fixture.detectChanges();
flush();
Expand Down Expand Up @@ -289,7 +272,7 @@ describe('tree-select component', () => {

it('should set null value work', fakeAsync(() => {
fixture.detectChanges();
expect(testComponent.value[0]).toBe('1000122');
expect(testComponent.value[ 0 ]).toBe('1000122');
testComponent.setNull();
fixture.detectChanges();
tick();
Expand Down Expand Up @@ -327,7 +310,7 @@ describe('tree-select component', () => {
fixture.detectChanges();
expect(treeSelectComponent.nzOpen).toBe(true);
fixture.detectChanges();
const targetNode = overlayContainerElement.querySelectorAll('nz-tree-node')[2];
const targetNode = overlayContainerElement.querySelectorAll('nz-tree-node')[ 2 ];
dispatchMouseEvent(targetNode, 'click');
fixture.detectChanges();
flush();
Expand Down Expand Up @@ -429,7 +412,7 @@ describe('tree-select component', () => {
})
export class NzTestTreeSelectBasicComponent {
@ViewChild(NzTreeSelectComponent) nzSelectTreeComponent: NzTreeSelectComponent;
expandKeys = ['1001', '10001'];
expandKeys = [ '1001', '10001' ];
value = '10001';
size = 'default';
allowClear = false;
Expand All @@ -438,31 +421,31 @@ export class NzTestTreeSelectBasicComponent {
dropdownMatchSelectWidth = true;
nodes = [
new NzTreeNode({
title: 'root1',
key: '1001',
title : 'root1',
key : '1001',
children: [
{
title: 'child1',
key: '10001',
title : 'child1',
key : '10001',
children: [
{
title: 'child1.1',
key: '100011',
title : 'child1.1',
key : '100011',
children: []
},
{
title: 'child1.2',
key: '100012',
title : 'child1.2',
key : '100012',
children: [
{
title: 'grandchild1.2.1',
key: '1000121',
isLeaf: true,
title : 'grandchild1.2.1',
key : '1000121',
isLeaf : true,
disabled: true
},
{
title: 'grandchild1.2.2',
key: '1000122',
title : 'grandchild1.2.2',
key : '1000122',
isLeaf: true
}
]
Expand All @@ -472,22 +455,22 @@ export class NzTestTreeSelectBasicComponent {
]
}),
new NzTreeNode({
title: 'root2',
key: '1002',
title : 'root2',
key : '1002',
children: [
{
title: 'child2.1',
key: '10021',
children: [],
title : 'child2.1',
key : '10021',
children : [],
disableCheckbox: true
},
{
title: 'child2.2',
key: '10022',
title : 'child2.2',
key : '10022',
children: [
{
title: 'grandchild2.2.1',
key: '100221',
title : 'grandchild2.2.1',
key : '100221',
isLeaf: true
}
]
Expand Down Expand Up @@ -517,36 +500,36 @@ export class NzTestTreeSelectBasicComponent {
})
export class NzTestTreeSelectCheckableComponent {
@ViewChild(NzTreeSelectComponent) nzSelectTreeComponent: NzTreeSelectComponent;
expandKeys = ['1001', '10001'];
value = ['1000122'];
expandKeys = [ '1001', '10001' ];
value = [ '1000122' ];
showSearch = false;
nodes = [
new NzTreeNode({
title: 'root1',
key: '1001',
title : 'root1',
key : '1001',
children: [
{
title: 'child1',
key: '10001',
title : 'child1',
key : '10001',
children: [
{
title: 'child1.1',
key: '100011',
title : 'child1.1',
key : '100011',
children: []
},
{
title: 'child1.2',
key: '100012',
title : 'child1.2',
key : '100012',
children: [
{
title: 'grandchild1.2.1',
key: '1000121',
isLeaf: true,
title : 'grandchild1.2.1',
key : '1000121',
isLeaf : true,
disabled: true
},
{
title: 'grandchild1.2.2',
key: '1000122',
title : 'grandchild1.2.2',
key : '1000122',
isLeaf: true
}
]
Expand All @@ -556,22 +539,22 @@ export class NzTestTreeSelectCheckableComponent {
]
}),
new NzTreeNode({
title: 'root2',
key: '1002',
title : 'root2',
key : '1002',
children: [
{
title: 'child2.1',
key: '10021',
children: [],
title : 'child2.1',
key : '10021',
children : [],
disableCheckbox: true
},
{
title: 'child2.2',
key: '10022',
title : 'child2.2',
key : '10022',
children: [
{
title: 'grandchild2.2.1',
key: '100221',
title : 'grandchild2.2.1',
key : '100221',
isLeaf: true
}
]
Expand Down Expand Up @@ -601,16 +584,16 @@ export class NzTestTreeSelectFormComponent {
formGroup: FormGroup;
nodes = [
new NzTreeNode({
title: 'root2',
key: '1002',
title : 'root2',
key : '1002',
children: [
{
title: 'child2.1',
key: '10021'
key : '10021'
},
{
title: 'child2.2',
key: '10022'
key : '10022'
}
]
})
Expand Down

0 comments on commit 6c63673

Please sign in to comment.