Skip to content

Commit

Permalink
mgr/dashboard: Fix the table mouseenter event handling test
Browse files Browse the repository at this point in the history
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 <smueller@suse.com>
(cherry picked from commit efc7999)

Conflicts (trivial + linting issue):
	src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts
  • Loading branch information
Stephan Müller committed Jul 30, 2019
1 parent 85fa207 commit b15077d
Showing 1 changed file with 11 additions and 3 deletions.
Expand Up @@ -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', () => {
Expand Down

0 comments on commit b15077d

Please sign in to comment.