8
0
Просмотр исходного кода

Tests: Existing tests should also reuse generateResizeTest whenever possible.

Marek Lewandowski 6 лет назад
Родитель
Сommit
b463c4bce4
1 измененных файлов с 11 добавлено и 17 удалено
  1. 11 17
      packages/ckeditor5-widget/tests/widgetresize.js

+ 11 - 17
packages/ckeditor5-widget/tests/widgetresize.js

@@ -148,25 +148,19 @@ describe( 'WidgetResize', () => {
 			expect( commitStub.callCount ).to.be.equal( 2 );
 			expect( commitStub.callCount ).to.be.equal( 2 );
 		} );
 		} );
 
 
-		it( 'shrinks correctly with bottom-left handler', () => {
-			const usedResizer = 'bottom-left';
-			const domParts = getWidgetDomParts( widget, usedResizer );
-			const finalPointerPosition = getHandleCenterPoint( domParts.widget, usedResizer ).moveBy( 10, -10 );
-
-			mouseMock.dragTo( editor, domParts.resizeHandle, finalPointerPosition );
-			sinon.assert.calledWithExactly( commitStub.firstCall, '90px' );
-			sinon.assert.calledOnce( commitStub );
-		} );
+		// --- bottom handlers ---
 
 
-		it( 'shrinks correctly with bottom-right handler', () => {
-			const usedResizer = 'bottom-right';
-			const domParts = getWidgetDomParts( widget, usedResizer );
-			const finalPointerPosition = getHandleCenterPoint( domParts.widget, usedResizer ).moveBy( -10, -10 );
+		it( 'shrinks correctly with bottom-left handler', generateResizeTest( {
+			usedHandle: 'bottom-left',
+			movePointerBy: { x: 10, y: -10 },
+			expectedWidth: '90px'
+		} ) );
 
 
-			mouseMock.dragTo( editor, domParts.resizeHandle, finalPointerPosition );
-			sinon.assert.calledWithExactly( commitStub.firstCall, '90px' );
-			sinon.assert.calledOnce( commitStub );
-		} );
+		it( 'shrinks correctly with bottom-right handler', generateResizeTest( {
+			usedHandle: 'bottom-right',
+			movePointerBy: { x: -10, y: -10 },
+			expectedWidth: '90px'
+		} ) );
 
 
 		it( 'enlarges correctly with bottom-right handler, x axis only', generateResizeTest( {
 		it( 'enlarges correctly with bottom-right handler, x axis only', generateResizeTest( {
 			usedHandle: 'bottom-right',
 			usedHandle: 'bottom-right',