Ver código fonte

Tests: Move initialization into a single function.

Marek Lewandowski 5 anos atrás
pai
commit
9326dd3244
1 arquivos alterados com 13 adições e 22 exclusões
  1. 13 22
      packages/ckeditor5-widget/tests/widgetresize.js

+ 13 - 22
packages/ckeditor5-widget/tests/widgetresize.js

@@ -17,23 +17,7 @@ import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-util
 import { mouseMock, focusEditor, getHandleCenterPoint, getWidgetDomParts } from './widgetresize/_utils/utils';
 
 describe( 'WidgetResize', () => {
-	let editor, editorElement, widget, mouseListenerSpies;
-
-	const commitStub = sinon.stub();
-
-	before( () => {
-		mouseListenerSpies = {
-			down: sinon.spy( WidgetResize.prototype, '_mouseDownListener' ),
-			move: sinon.spy( WidgetResize.prototype, '_mouseMoveListener' ),
-			up: sinon.spy( WidgetResize.prototype, '_mouseUpListener' )
-		};
-	} );
-
-	after( () => {
-		for ( const stub of Object.values( mouseListenerSpies ) ) {
-			stub.restore();
-		}
-	} );
+	let editor, editorElement, widget, mouseListenerSpies, commitStub;
 
 	beforeEach( async () => {
 		editorElement = createEditorElement();
@@ -45,21 +29,28 @@ describe( 'WidgetResize', () => {
 
 		widget = editor.editing.view.document.getRoot().getChild( 0 );
 
-		for ( const stub of Object.values( mouseListenerSpies ) ) {
-			stub.resetHistory();
-		}
-		commitStub.resetHistory();
-
 		// It's crucial to have a precisely defined editor size for this test suite.
 		editor.editing.view.change( writer => {
 			const viewEditableRoot = editor.editing.view.document.getRoot();
 			writer.setAttribute( 'style', 'width: 400px; padding: 0px; overflow: hidden', viewEditableRoot );
 		} );
+
+		commitStub = sinon.stub();
+
+		mouseListenerSpies = {
+			down: sinon.spy( WidgetResize.prototype, '_mouseDownListener' ),
+			move: sinon.spy( WidgetResize.prototype, '_mouseMoveListener' ),
+			up: sinon.spy( WidgetResize.prototype, '_mouseUpListener' )
+		};
 	} );
 
 	afterEach( () => {
 		editorElement.remove();
 
+		for ( const stub of Object.values( mouseListenerSpies ) ) {
+			stub.restore();
+		}
+
 		if ( editor ) {
 			return editor.destroy();
 		}