浏览代码

Tests: Added BalloonPanelView tests to verify if limiter and target can be functions.

Aleksander Nowodzinski 8 年之前
父节点
当前提交
420eac1d45
共有 1 个文件被更改,包括 17 次插入1 次删除
  1. 17 1
      packages/ckeditor5-ui/tests/panel/balloon/balloonpanelview.js

+ 17 - 1
packages/ckeditor5-ui/tests/panel/balloon/balloonpanelview.js

@@ -614,6 +614,22 @@ describe( 'BalloonPanelView', () => {
 				sinon.assert.calledTwice( attachToSpy );
 			} );
 
+			it( 'should work for a function as a target/limiter', () => {
+				// Just check if this normally works without errors.
+				const rect = {};
+
+				view.pin( {
+					target() { return rect; },
+					limiter() { return limiter; }
+				} );
+
+				sinon.assert.calledOnce( attachToSpy );
+
+				limiter.dispatchEvent( new Event( 'scroll' ) );
+
+				sinon.assert.calledTwice( attachToSpy );
+			} );
+
 			// https://github.com/ckeditor/ckeditor5-ui/issues/227
 			it( 'should react to #scroll from anywhere when the target is not an HTMLElement or Range', () => {
 				const rect = {};
@@ -626,7 +642,7 @@ describe( 'BalloonPanelView', () => {
 			} );
 
 			// https://github.com/ckeditor/ckeditor5-ui/issues/260
-			it( 'should react to #scroll from anywhere when the limiter is not an HTMLElement or Range', () => {
+			it( 'should react to #scroll from anywhere when the limiter is not an HTMLElement` or Range', () => {
 				const rect = {};
 
 				view.pin( { target, limiter: rect } );