Browse Source

Improved test.

Oskar Wróbel 8 years ago
parent
commit
69f4a2cd1d
1 changed files with 5 additions and 2 deletions
  1. 5 2
      packages/ckeditor5-ui/tests/panel/balloon/balloonpanelview.js

+ 5 - 2
packages/ckeditor5-ui/tests/panel/balloon/balloonpanelview.js

@@ -406,14 +406,17 @@ describe( 'BalloonPanelView', () => {
 	} );
 	} );
 
 
 	describe( 'keepAttachedTo()', () => {
 	describe( 'keepAttachedTo()', () => {
-		let attachToSpy, target, limiter, notRelatedElement;
+		let attachToSpy, target, targetParent, limiter, notRelatedElement;
 
 
 		beforeEach( () => {
 		beforeEach( () => {
 			attachToSpy = testUtils.sinon.spy( view, 'attachTo' );
 			attachToSpy = testUtils.sinon.spy( view, 'attachTo' );
 			limiter = document.createElement( 'div' );
 			limiter = document.createElement( 'div' );
+			targetParent = document.createElement( 'div' );
 			target = document.createElement( 'div' );
 			target = document.createElement( 'div' );
 			notRelatedElement = document.createElement( 'div' );
 			notRelatedElement = document.createElement( 'div' );
 
 
+			targetParent.appendChild( target );
+			document.body.appendChild( targetParent );
 			document.body.appendChild( limiter );
 			document.body.appendChild( limiter );
 			document.body.appendChild( notRelatedElement );
 			document.body.appendChild( notRelatedElement );
 		} );
 		} );
@@ -430,7 +433,7 @@ describe( 'BalloonPanelView', () => {
 			sinon.assert.calledOnce( attachToSpy );
 			sinon.assert.calledOnce( attachToSpy );
 			sinon.assert.calledWith( attachToSpy.lastCall, { target, limiter } );
 			sinon.assert.calledWith( attachToSpy.lastCall, { target, limiter } );
 
 
-			document.dispatchEvent( new Event( 'scroll' ) );
+			targetParent.dispatchEvent( new Event( 'scroll' ) );
 
 
 			sinon.assert.calledTwice( attachToSpy );
 			sinon.assert.calledTwice( attachToSpy );
 			sinon.assert.calledWith( attachToSpy.lastCall, { target, limiter } );
 			sinon.assert.calledWith( attachToSpy.lastCall, { target, limiter } );