Merge pull request #28879 from Devp00l/wip-40580

mgr/dashboard: Fix the table mouseenter event handling test

Reviewed-by: Patrick Nawracay <pnawracay@suse.com>
Reviewed-by: Tiago Melo <tmelo@suse.com>
This commit is contained in:
Ricardo Dias 2019-07-16 11:48:39 +01:00 committed by GitHub
commit d4049a5ad6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View File

@ -87,10 +87,18 @@ describe('TableComponent', () => {
});
it('should prevent propagation of mouseenter event', (done) => {
fixture.detectChanges();
let wasCalled = false;
const mouseEvent = new MouseEvent('mouseenter');
mouseEvent.stopPropagation = () => done();
fixture.debugElement.nativeElement.dispatchEvent(mouseEvent);
mouseEvent.stopPropagation = () => {
wasCalled = true;
};
spyOn(window, 'addEventListener').and.callFake((eventName, fn) => {
fn(mouseEvent);
expect(eventName).toBe('mouseenter');
expect(wasCalled).toBe(true);
done();
});
component.ngOnInit();
});
describe('test search', () => {

View File

@ -179,14 +179,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O
ngOnInit() {
// ngx-datatable triggers calculations each time mouse enters a row,
// this will prevent that.
window.addEventListener(
'mouseenter',
function(event) {
event.stopPropagation();
},
true
);
window.addEventListener('mouseenter', (event) => event.stopPropagation(), true);
this._addTemplates();
if (!this.sorts) {
// Check whether the specified identifier exists.