diff --git a/components/cascader/nz-cascader.component.ts b/components/cascader/nz-cascader.component.ts index e6e3e77f794..ac9c008e2bc 100644 --- a/components/cascader/nz-cascader.component.ts +++ b/components/cascader/nz-cascader.component.ts @@ -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); diff --git a/components/cascader/nz-cascader.spec.ts b/components/cascader/nz-cascader.spec.ts index 228da7ffe8c..fbe033d25dc 100644 --- a/components/cascader/nz-cascader.spec.ts +++ b/components/cascader/nz-cascader.spec.ts @@ -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();