Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should clear timer on option mouseenter and mouseleave', fakeAsync(() => {
const mouseenter = createMouseEvent('mouseenter');
const mouseleave = createMouseEvent('mouseleave');
const option = options1[0]; // zhejiang
testComponent.nzExpandTrigger = 'hover';
fixture.detectChanges();
expect(testComponent.cascader.menuVisible).toBe(false);
testComponent.cascader.setMenuVisible(true);
fixture.detectChanges();
expect(testComponent.cascader.menuVisible).toBe(true);
flush();
fixture.detectChanges();
const optionEl = getItemAtColumnAndRow(1, 1)!;
expect(optionEl.classList).not.toContain('ant-cascader-menu-item-active');
testComponent.cascader.onOptionMouseEnter(option, 0, mouseenter);
fixture.detectChanges();
it('should create dropdown', () => {
const fakeEvent = createMouseEvent('contextmenu', 300, 300);
testComponent.nzDropdownService.create(fakeEvent, testComponent.template);
fixture.detectChanges();
expect(overlayContainerElement.textContent).not.toBe('');
// https://github.com/angular/material2/pull/12119
// TODO: fix
// expect(window.getComputedStyle(overlayPane, null).top).toBe(`${300 - overlayContainerElement.getBoundingClientRect().top}px`);
testComponent.nzDropdownService.dispose();
fixture.detectChanges();
expect(overlayContainerElement.textContent).toBe('');
});
it('should only one dropdown exist', () => {
it('should change contextmenu after create', fakeAsync(() => {
const fakeEvent = createMouseEvent('contextmenu', 100, 100);
testComponent.nzDropdownService.create(fakeEvent, testComponent.template);
fixture.detectChanges();
tick(500);
fixture.detectChanges();
const fakeContextEvent = createMouseEvent('contextmenu', 200, 200);
testComponent.nzDropdownService.create(fakeContextEvent, testComponent.template);
fixture.detectChanges();
tick(1000);
fixture.detectChanges();
// @ts-ignore
const overlayElement = testComponent.nzDropdownService.overlayRef.overlayElement;
expect(overlayElement.textContent).not.toBe('');
}));
});
it('should clear timer on option mouseenter and mouseleave', fakeAsync(() => {
const mouseenter = createMouseEvent('mouseenter');
const mouseleave = createMouseEvent('mouseleave');
const option = options1[0]; // zhejiang
testComponent.nzExpandTrigger = 'hover';
fixture.detectChanges();
expect(testComponent.cascader.menuVisible).toBe(false);
testComponent.cascader.setMenuVisible(true);
fixture.detectChanges();
expect(testComponent.cascader.menuVisible).toBe(true);
flush();
fixture.detectChanges();
const optionEl = getItemAtColumnAndRow(1, 1)!;
expect(optionEl.classList).not.toContain('ant-cascader-menu-item-active');
testComponent.cascader.onOptionMouseEnter(option, 0, mouseenter);
fixture.detectChanges();
tick(10);
it('should only one dropdown exist', () => {
let fakeEvent = createMouseEvent('contextmenu', 0, 0);
testComponent.nzDropdownService.create(fakeEvent, testComponent.template);
fixture.detectChanges();
expect(overlayContainerElement.textContent).not.toBe('');
fakeEvent = createMouseEvent('contextmenu', window.innerWidth, window.innerHeight);
testComponent.nzDropdownService.create(fakeEvent, testComponent.template);
fixture.detectChanges();
expect(overlayContainerElement.textContent).toBe('');
});
it('should dropdown close when scroll', () => {
it('should backdrop work with click', fakeAsync(() => {
const fakeEvent = createMouseEvent('contextmenu', 100, 100);
testComponent.nzDropdownService.create(fakeEvent, testComponent.template);
fixture.detectChanges();
expect(overlayContainerElement.textContent).not.toBe('');
document.body.click();
tick(500);
fixture.detectChanges();
expect(overlayContainerElement.textContent).toBe('');
}));
it('should change contextmenu after create', fakeAsync(() => {
it('should only one dropdown exist', () => {
let fakeEvent = createMouseEvent('contextmenu', 0, 0);
testComponent.nzDropdownService.create(fakeEvent, testComponent.template);
fixture.detectChanges();
expect(overlayContainerElement.textContent).not.toBe('');
fakeEvent = createMouseEvent('contextmenu', window.innerWidth, window.innerHeight);
testComponent.nzDropdownService.create(fakeEvent, testComponent.template);
fixture.detectChanges();
expect(overlayContainerElement.textContent).toBe('');
});
it('should dropdown close when scroll', () => {
it('should animation work', () => {
const fakeEvent = createMouseEvent('contextmenu', 500, 500);
const contextComponent = testComponent.nzDropdownService.create(fakeEvent, testComponent.template);
fixture.detectChanges();
expect(overlayContainerElement.textContent).not.toBe('');
contextComponent.close();
contextComponent.afterAnimation();
fixture.detectChanges();
expect(overlayContainerElement.textContent).toBe('');
});
it('should backdrop work with click', fakeAsync(() => {