AAE-12245: Migrated from event cancelBubble to stopPropagation (#8311)

This commit is contained in:
Ehsan Rezaei
2023-03-06 21:57:51 +01:00
committed by GitHub
parent cb69f34aa7
commit dd91f2eeb6
8 changed files with 70 additions and 18 deletions

View File

@@ -36,6 +36,7 @@ import {
} from '@alfresco/adf-core';
import { throwError } from 'rxjs';
import { Component } from '@angular/core';
import { ESCAPE } from '@angular/cdk/keycodes';
@Component({
selector: 'adf-viewer-container-toolbar',
@@ -407,6 +408,34 @@ describe('AlfrescoViewerComponent', () => {
});
});
it('should stop propagation on sidebar keydown event [keydown]', fakeAsync(() => {
const customFixture = TestBed.createComponent(ViewerWithCustomSidebarComponent);
const customElement: HTMLElement = customFixture.nativeElement;
const escapeKeyboardEvent = new KeyboardEvent('keydown', { key: ESCAPE.toString() });
const stopPropagationSpy = spyOn(escapeKeyboardEvent, 'stopPropagation');
customFixture.detectChanges();
const viewerSidebarElement = customElement.querySelector('adf-viewer-sidebar');
viewerSidebarElement.dispatchEvent(escapeKeyboardEvent);
expect(stopPropagationSpy).toHaveBeenCalled();
}));
it('should stop propagation on sidebar keyup event [keyup]', fakeAsync(() => {
const customFixture = TestBed.createComponent(ViewerWithCustomSidebarComponent);
const customElement: HTMLElement = customFixture.nativeElement;
const escapeKeyboardEvent = new KeyboardEvent('keyup', { key: ESCAPE.toString() });
const stopPropagationSpy = spyOn(escapeKeyboardEvent, 'stopPropagation');
customFixture.detectChanges();
const viewerSidebarElement = customElement.querySelector('adf-viewer-sidebar');
viewerSidebarElement.dispatchEvent(escapeKeyboardEvent);
expect(stopPropagationSpy).toHaveBeenCalled();
}));
});
describe('error handling', () => {