Procházet zdrojové kódy

Tests: Fixed tests leaking editor instance / DOM element.

Marek Lewandowski před 6 roky
rodič
revize
a36b80d74f

+ 10 - 2
packages/ckeditor5-font/tests/fontfamily/fontfamilyui.js

@@ -116,10 +116,18 @@ describe( 'FontFamilyUI', () => {
 		} );
 
 		describe( 'localization', () => {
-			beforeEach( () => {
+			let editorElement;
+
+			beforeEach( async () => {
+				await editor.destroy();
+
 				return localizedEditor( [ 'default', 'Arial' ] );
 			} );
 
+			afterEach( () => {
+				editorElement.remove();
+			} );
+
 			it( 'works for the #buttonView', () => {
 				const buttonView = dropdown.buttonView;
 
@@ -136,7 +144,7 @@ describe( 'FontFamilyUI', () => {
 			} );
 
 			function localizedEditor( options ) {
-				const editorElement = document.createElement( 'div' );
+				editorElement = document.createElement( 'div' );
 				document.body.appendChild( editorElement );
 
 				return ClassicTestEditor

+ 11 - 1
packages/ckeditor5-font/tests/fontsize/fontsizeui.js

@@ -120,6 +120,13 @@ describe( 'FontSizeUI', () => {
 		} );
 
 		describe( 'config', () => {
+			beforeEach( () => {
+				// Each test suite creates its own element, so make sure to delete editor created in root
+				// level first, as later element and editor vars are overridden.
+				element.remove();
+				return editor.destroy();
+			} );
+
 			describe( 'using presets', () => {
 				beforeEach( () => {
 					element = document.createElement( 'div' );
@@ -196,7 +203,10 @@ describe( 'FontSizeUI', () => {
 		} );
 
 		describe( 'localization', () => {
-			beforeEach( () => {
+			beforeEach( async () => {
+				element.remove();
+				await editor.destroy();
+
 				return localizedEditor( [ 'tiny', 'small', 'default', 'big', 'huge' ] );
 			} );