Forráskód Böngészése

Tests: Create and remove the editor correctly in the tests.

Piotrek Koszuliński 8 éve
szülő
commit
8ac1d22bb3
1 módosított fájl, 11 hozzáadás és 3 törlés
  1. 11 3
      packages/ckeditor5-heading/tests/heading.js

+ 11 - 3
packages/ckeditor5-heading/tests/heading.js

@@ -22,10 +22,10 @@ add( 'pl', {
 testUtils.createSinonSandbox();
 
 describe( 'Heading', () => {
-	let editor, dropdown;
+	let editor, editorElement, dropdown;
 
 	beforeEach( () => {
-		const editorElement = document.createElement( 'div' );
+		editorElement = document.createElement( 'div' );
 		document.body.appendChild( editorElement );
 
 		return ClassicTestEditor.create( editorElement, {
@@ -39,6 +39,8 @@ describe( 'Heading', () => {
 	} );
 
 	afterEach( () => {
+		editorElement.remove();
+
 		return editor.destroy();
 	} );
 
@@ -117,7 +119,7 @@ describe( 'Heading', () => {
 		} );
 
 		describe( 'localization', () => {
-			let commands;
+			let commands, editor, dropdown;
 
 			beforeEach( () => {
 				return localizedEditor( [
@@ -186,6 +188,7 @@ describe( 'Heading', () => {
 
 			function localizedEditor( options ) {
 				const editorElement = document.createElement( 'div' );
+				document.body.appendChild( editorElement );
 
 				return ClassicTestEditor.create( editorElement, {
 					plugins: [ Heading ],
@@ -199,9 +202,14 @@ describe( 'Heading', () => {
 					editor = newEditor;
 					dropdown = editor.ui.componentFactory.create( 'headings' );
 					commands = {};
+
 					editor.config.get( 'heading.options' ).forEach( ( { modelElement } ) => {
 						commands[ modelElement ] = editor.commands.get( modelElement );
 					} );
+
+					editorElement.remove();
+
+					return editor.destroy();
 				} );
 			}
 		} );