Explorar o código

Tests: Fixed tests leaking editor instance / DOM element.

Marek Lewandowski %!s(int64=6) %!d(string=hai) anos
pai
achega
ca21a8a5b7
Modificáronse 1 ficheiros con 11 adicións e 1 borrados
  1. 11 1
      packages/ckeditor5-editor-classic/tests/classiceditor.js

+ 11 - 1
packages/ckeditor5-editor-classic/tests/classiceditor.js

@@ -209,8 +209,16 @@ describe( 'ClassicEditor', () => {
 				initialData: '<p>I am evil!</p>',
 				plugins: [ Paragraph ]
 			} ).catch( () => {
+				removeEditorDom();
 				done();
 			} );
+
+			function removeEditorDom() {
+				// Remove DOM leftovers to not affect other tests (#6002, #6018).
+				for ( const editorBody of document.body.querySelectorAll( 'div.ck.ck-body' ) ) {
+					editorBody.remove();
+				}
+			}
 		} );
 
 		it( 'should have undefined the #sourceElement if editor was initialized with data', () => {
@@ -309,7 +317,9 @@ describe( 'ClassicEditor', () => {
 				} );
 		} );
 
-		it( 'does not update the source element if editor was initialized with data', () => {
+		it( 'does not update the source element if editor was initialized with data', async () => {
+			await editor.destroy();
+
 			return ClassicEditor
 				.create( '<p>Foo.</p>', {
 					plugins: [ Paragraph, Bold ]