From d54103d13747069f76052e062c60ecdd29c21b5e Mon Sep 17 00:00:00 2001 From: Marek Lewandowski Date: Fri, 20 Dec 2019 04:27:47 +0100 Subject: [PATCH 1/2] Tests: Fixed tests leaking editor instance / DOM element. --- tests/classiceditor.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/classiceditor.js b/tests/classiceditor.js index 8a0b139..0e221a1 100644 --- a/tests/classiceditor.js +++ b/tests/classiceditor.js @@ -209,8 +209,16 @@ describe( 'ClassicEditor', () => { initialData: '

I am evil!

', 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( '

Foo.

', { plugins: [ Paragraph, Bold ] From adaf68512d9397a9fb2369ffc051cd8065c0c172 Mon Sep 17 00:00:00 2001 From: Marek Lewandowski Date: Fri, 3 Jan 2020 16:10:52 +0100 Subject: [PATCH 2/2] Tests: Reuse the removeEditorBodyOrphans function. --- tests/classiceditor.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/classiceditor.js b/tests/classiceditor.js index 0e221a1..4a519f8 100644 --- a/tests/classiceditor.js +++ b/tests/classiceditor.js @@ -22,6 +22,7 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils'; import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset'; import { describeMemoryUsage, testMemoryUsage } from '@ckeditor/ckeditor5-core/tests/_utils/memory'; +import { removeEditorBodyOrphans } from '@ckeditor/ckeditor5-core/tests/_utils/cleanup'; describe( 'ClassicEditor', () => { let editor, editorElement; @@ -209,16 +210,9 @@ describe( 'ClassicEditor', () => { initialData: '

I am evil!

', plugins: [ Paragraph ] } ).catch( () => { - removeEditorDom(); + removeEditorBodyOrphans(); 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', () => {