Skip to content

Commit

Permalink
fix spec file
Browse files Browse the repository at this point in the history
  • Loading branch information
gaomd committed Aug 19, 2018
1 parent d5251c7 commit f1bb61c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 74 deletions.
2 changes: 1 addition & 1 deletion components/cascader/nz-cascader.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ export class NzCascaderComponent implements OnInit, OnDestroy, ControlValueAcces
this.clearDelaySelectTimer();
if (doSelect) {
this.delaySelectTimer = setTimeout(() => {
// 鼠标滑入只展开 children 不进行选中操作
// 鼠标滑入只展开不进行选中操作
this.setActiveOption(option, index);
this.delaySelectTimer = null;
}, 150);
Expand Down
73 changes: 0 additions & 73 deletions components/cascader/nz-cascader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1176,79 +1176,6 @@ describe('cascader', () => {
expect(overlayContainerElement.querySelectorAll('.ant-cascader-menu').length).toBe(0); // 0列
expect(testComponent.cascader.isMenuVisible()).toBe(false);
}));
it('should change on hover work', fakeAsync(() => {
testComponent.nzChangeOnSelect = true;
testComponent.nzExpandTrigger = 'hover';
fixture.detectChanges();
expect(testComponent.values).toBeNull();
expect(overlayContainerElement.querySelectorAll('.ant-cascader-menu').length).toBe(0); // 0列
expect(testComponent.values).toBeNull(); // not select yet

testComponent.cascader.setMenuVisible(true);
fixture.detectChanges();
expect(overlayContainerElement.querySelectorAll('.ant-cascader-menu').length).toBe(1); // 1列
expect(testComponent.values).toBeNull(); // not select yet

const itemEl1 = overlayContainerElement.querySelector('.ant-cascader-menu:nth-child(1) .ant-cascader-menu-item:nth-child(1)') as HTMLElement; // 第1列第1个
expect(itemEl1.classList).not.toContain('ant-cascader-menu-item-active');
dispatchMouseEvent(itemEl1, 'mouseenter');
fixture.detectChanges();
tick(200);
fixture.detectChanges();

expect(testComponent.cascader.isMenuVisible()).toBe(true);
expect(itemEl1.classList).toContain('ant-cascader-menu-item-active');
expect(overlayContainerElement.querySelectorAll('.ant-cascader-menu').length).toBe(2); // 2列
expect(testComponent.values).toBeDefined();
expect(testComponent.values.length).toBe(1);
expect(testComponent.values[ 0 ]).toBe('zhejiang');

const itemEl2 = overlayContainerElement.querySelector('.ant-cascader-menu:nth-child(2) .ant-cascader-menu-item:nth-child(1)') as HTMLElement; // 第2列第1个
expect(itemEl1.classList).toContain('ant-cascader-menu-item-active');
expect(itemEl2.classList).not.toContain('ant-cascader-menu-item-active');
dispatchMouseEvent(itemEl2, 'mouseenter');
fixture.detectChanges();
tick(200);
fixture.detectChanges();

expect(testComponent.cascader.isMenuVisible()).toBe(true);
expect(itemEl1.classList).toContain('ant-cascader-menu-item-active');
expect(itemEl2.classList).toContain('ant-cascader-menu-item-active');
expect(overlayContainerElement.querySelectorAll('.ant-cascader-menu').length).toBe(3); // 3列
expect(testComponent.values).toBeDefined();
expect(testComponent.values.length).toBe(2);
expect(testComponent.values[ 0 ]).toBe('zhejiang');
expect(testComponent.values[ 1 ]).toBe('hangzhou');

const itemEl3 = overlayContainerElement.querySelector('.ant-cascader-menu:nth-child(3) .ant-cascader-menu-item:nth-child(1)') as HTMLElement; // 第3列第1个
expect(itemEl1.classList).toContain('ant-cascader-menu-item-active');
expect(itemEl2.classList).toContain('ant-cascader-menu-item-active');
expect(itemEl3.classList).not.toContain('ant-cascader-menu-item-active');
dispatchMouseEvent(itemEl3, 'mouseenter');
fixture.detectChanges();
tick(200);
fixture.detectChanges();

expect(testComponent.values).toBeDefined();
expect(testComponent.values.length).toBe(2);
expect(testComponent.values[ 0 ]).toBe('zhejiang');
expect(testComponent.values[ 1 ]).toBe('hangzhou');

itemEl3.click();
fixture.detectChanges();
tick(200);
fixture.detectChanges();

expect(testComponent.values).toBeDefined();
expect(testComponent.values.length).toBe(3);
expect(testComponent.values[ 0 ]).toBe('zhejiang');
expect(testComponent.values[ 1 ]).toBe('hangzhou');
expect(testComponent.values[ 2 ]).toBe('xihu');
flush(); // wait for cdk-overlay to close
fixture.detectChanges();
expect(overlayContainerElement.querySelectorAll('.ant-cascader-menu').length).toBe(0); // 0列
expect(testComponent.cascader.isMenuVisible()).toBe(false);
}));
it('should change on function work', fakeAsync(() => {
testComponent.nzChangeOn = testComponent.fakeChangeOn;
fixture.detectChanges();
Expand Down

0 comments on commit f1bb61c

Please sign in to comment.