8
0
فهرست منبع

Tests: Code refactoring.

Aleksander Nowodzinski 6 سال پیش
والد
کامیت
bcbb4d5d26
1فایلهای تغییر یافته به همراه16 افزوده شده و 18 حذف شده
  1. 16 18
      packages/ckeditor5-editor-decoupled/tests/decouplededitor.js

+ 16 - 18
packages/ckeditor5-editor-decoupled/tests/decouplededitor.js

@@ -126,25 +126,23 @@ describe( 'DecoupledEditor', () => {
 		} );
 
 		// See: https://github.com/ckeditor/ckeditor5/issues/746
-		it( 'should throw when trying to create the editor using the same source element more than once', () => {
+		it( 'should throw when trying to create the editor using the same source element more than once', done => {
 			const sourceElement = document.createElement( 'div' );
-			let editor;
-
-			return DecoupledEditor.create( sourceElement )
-				.then( newEditor => {
-					editor = newEditor;
-
-					return new DecoupledEditor( sourceElement );
-				} )
-				.then( () => {
-					expect.fail( 'Decoupled editor should not initialize on an element already used by other instance.' );
-				} )
-				.catch( err => {
-					assertCKEditorError( err, /^editor-source-element-used-more-than-once/ );
-				} )
-				.finally( () => {
-					return editor.destroy();
-				} );
+
+			// eslint-disable-next-line no-new
+			new DecoupledEditor( sourceElement );
+
+			DecoupledEditor.create( sourceElement )
+				.then(
+					() => {
+						expect.fail( 'Decoupled editor should not initialize on an element already used by other instance.' );
+					},
+					err => {
+						assertCKEditorError( err, /^securesourceelement-element-used-more-than-once/ );
+					}
+				)
+				.then( done )
+				.catch( done );
 		} );
 
 		it( 'throws if initial data is passed in Editor#create and config.initialData is also used', done => {