From: Stephan Müller Date: Fri, 5 Jul 2019 09:54:40 +0000 (+0200) Subject: mgr/dashboard: Fix the table mouseenter event handling test X-Git-Tag: v14.2.3~23^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b15077d1a50c9b9d5f1a3486846b404aaf5502d3;p=ceph.git mgr/dashboard: Fix the table mouseenter event handling test This test only failed if all suites were run, for some reason the window object got replaced with a mock window. The workaround is not to use the window object, but mock the called function in order to call the values as expected by window. Fixes: https://tracker.ceph.com/issues/40580 Signed-off-by: Stephan Müller (cherry picked from commit efc79990b25cd6fe4be1ab640305aaa6c829740d) Conflicts (trivial + linting issue): src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts index 1d4ddeaef23..780192b0b9e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts @@ -88,10 +88,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(); }); it('should force an identifier', () => {