8
0
Quellcode durchsuchen

Tests: Make getHandleCenterPoint a shared util.

Marek Lewandowski vor 6 Jahren
Ursprung
Commit
7b03b55c54

+ 1 - 25
packages/ckeditor5-widget/tests/widgetresize.js

@@ -14,8 +14,7 @@ import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articleplugi
 import { toWidget } from '../src/utils';
 import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
-import Rect from '@ckeditor/ckeditor5-utils/src/dom/rect';
-import { mouseMock, getWidgetDomParts, Point } from './widgetresize/_utils/utils';
+import { mouseMock, getHandleCenterPoint, getWidgetDomParts } from './widgetresize/_utils/utils';
 
 describe( 'WidgetResize', () => {
 	let editor, editorElement, widget, mouseListenerSpies;
@@ -461,29 +460,6 @@ describe( 'WidgetResize', () => {
 		return editor.plugins.get( WidgetResize ).attachTo( Object.assign( defaultOptions, resizerOptions ) );
 	}
 
-	/**
-	 * Returns a center point for a given handle.
-	 *
-	 * @param {HTMLElement} domWrapper Wrapper of an element that contains the resizer.
-	 * @param {String} [handlePosition='top-left']
-	 * @returns {Point}
-	 */
-	function getHandleCenterPoint( domWrapper, handlePosition ) {
-		const wrapperRect = new Rect( domWrapper );
-		const returnValue = new Point( wrapperRect.left, wrapperRect.top );
-		const cornerPositionParts = handlePosition.split( '-' );
-
-		if ( cornerPositionParts.includes( 'right' ) ) {
-			returnValue.x = wrapperRect.right;
-		}
-
-		if ( cornerPositionParts.includes( 'bottom' ) ) {
-			returnValue.y = wrapperRect.bottom;
-		}
-
-		return returnValue;
-	}
-
 	function focusEditor( editor ) {
 		editor.editing.view.focus();
 		editor.ui.focusTracker.isFocused = true;

+ 25 - 0
packages/ckeditor5-widget/tests/widgetresize/_utils/utils.js

@@ -5,6 +5,8 @@
 
 import WidgetResize from '../../../src/widgetresize';
 
+import Rect from '@ckeditor/ckeditor5-utils/src/dom/rect';
+
 export const mouseMock = {
 	down( editor, domTarget ) {
 		this._getPlugin( editor )._mouseDownListener( {}, {
@@ -86,3 +88,26 @@ export class Point {
 		return new Point( this.x, this.y );
 	}
 }
+
+/**
+ * Returns a center point for a given handle.
+ *
+ * @param {HTMLElement} domWrapper Wrapper of an element that contains the resizer.
+ * @param {String} [handlePosition='top-left']
+ * @returns {Point}
+ */
+export function getHandleCenterPoint( domWrapper, handlePosition ) {
+	const wrapperRect = new Rect( domWrapper );
+	const returnValue = new Point( wrapperRect.left, wrapperRect.top );
+	const cornerPositionParts = handlePosition.split( '-' );
+
+	if ( cornerPositionParts.includes( 'right' ) ) {
+		returnValue.x = wrapperRect.right;
+	}
+
+	if ( cornerPositionParts.includes( 'bottom' ) ) {
+		returnValue.y = wrapperRect.bottom;
+	}
+
+	return returnValue;
+}