Explorar el Código

Tests: Updated orphans cleanup after introduction of the new body collection wrapper.

Piotrek Koszuliński hace 6 años
padre
commit
e6d1c6350a

+ 18 - 2
packages/ckeditor5-core/tests/_utils-tests/cleanup.js

@@ -11,7 +11,7 @@ import { removeEditorBodyOrphans } from '../_utils/cleanup';
 
 describe( 'cleanup util', () => {
 	describe( 'removeEditorBodyOrphans()', () => {
-		it( 'cleans up all editor elements', () => {
+		it( 'removes the body collection wrapper', () => {
 			const locale = new Locale();
 			const uiViews = [ new EditorUIView( locale ), new EditorUIView( locale ) ];
 
@@ -19,11 +19,27 @@ describe( 'cleanup util', () => {
 				view.render();
 			}
 
-			expect( document.querySelectorAll( '.ck-body' ) ).to.have.length( 2 );
+			// Body collection reuses its wrapper, hence 1.
+			expect( document.querySelectorAll( '.ck-body-wrapper' ) ).to.have.length( 1 );
 
 			removeEditorBodyOrphans();
 
+			expect( document.querySelectorAll( '.ck-body-wrapper' ) ).to.have.length( 0 );
 			expect( document.querySelectorAll( '.ck-body' ) ).to.have.length( 0 );
 		} );
+
+		// Right now, body collection should reuse its wrapper, but it doesn't cost us much to
+		// ensure that we remove all.
+		it( 'removes all body collection wrappers', () => {
+			const wrapper = document.createElement( 'div' );
+			wrapper.classList.add( 'ck-body-wrapper' );
+
+			document.body.appendChild( wrapper );
+			document.body.appendChild( wrapper.cloneNode() );
+
+			removeEditorBodyOrphans();
+
+			expect( document.querySelectorAll( '.ck-body-wrapper' ) ).to.have.length( 0 );
+		} );
 	} );
 } );

+ 1 - 1
packages/ckeditor5-core/tests/_utils/cleanup.js

@@ -13,7 +13,7 @@
  * See https://github.com/ckeditor/ckeditor5/issues/6018 for more details.
  */
 export function removeEditorBodyOrphans() {
-	for ( const bodyOrphan of document.querySelectorAll( '.ck-body' ) ) {
+	for ( const bodyOrphan of document.querySelectorAll( '.ck-body-wrapper' ) ) {
 		bodyOrphan.remove();
 	}
 }