8
0
فهرست منبع

Tests: Moved destroyEditorOrphans from core to the watchdog package.

https://github.com/ckeditor/ckeditor5-core/pull/207/files#r363643104
Marek Lewandowski 6 سال پیش
والد
کامیت
7701802dba
1فایلهای تغییر یافته به همراه16 افزوده شده و 1 حذف شده
  1. 16 1
      packages/ckeditor5-watchdog/tests/watchdog.js

+ 16 - 1
packages/ckeditor5-watchdog/tests/watchdog.js

@@ -12,7 +12,6 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 import { expectToThrowCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
-import { destroyEditorOrphans } from '@ckeditor/ckeditor5-core/tests/_utils/cleanup';
 
 describe( 'Watchdog', () => {
 	let element;
@@ -721,6 +720,22 @@ describe( 'Watchdog', () => {
 				} );
 			} );
 		} );
+
+		// Searches for orphaned editors based on DOM.
+		//
+		// This is useful if in your tests you have no access to editor, instance because editor
+		// creation method doesn't complete in a graceful manner.
+		function destroyEditorOrphans() {
+			const promises = [];
+
+			for ( const editableOrphan of document.querySelectorAll( '.ck-editor__editable' ) ) {
+				if ( editableOrphan.ckeditorInstance ) {
+					promises.push( editableOrphan.ckeditorInstance.destroy() );
+				}
+			}
+
+			return Promise.all( promises );
+		}
 	} );
 
 	describe( 'async error handling', () => {