From 3a4564cb8bfda3d0f1fdb14e2329a1a9228731e8 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/decouplededitor.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/decouplededitor.js b/tests/decouplededitor.js index ef59496..a264ccd 100644 --- a/tests/decouplededitor.js +++ b/tests/decouplededitor.js @@ -186,8 +186,18 @@ describe( 'DecoupledEditor', () => { ); } ) + .then( () => { + removeEditorDom(); + } ) .then( done ) .catch( 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( 'throws error if it is initialized in textarea', done => { From b70fa367729a495bfb9bdbeee7fc94fa054ac9fa Mon Sep 17 00:00:00 2001 From: Marek Lewandowski Date: Fri, 3 Jan 2020 16:11:40 +0100 Subject: [PATCH 2/2] Tests: Reuse the removeEditorBodyOrphans function. --- tests/decouplededitor.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/decouplededitor.js b/tests/decouplededitor.js index a264ccd..fe0a62d 100644 --- a/tests/decouplededitor.js +++ b/tests/decouplededitor.js @@ -22,6 +22,7 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils'; import { describeMemoryUsage, testMemoryUsage } from '@ckeditor/ckeditor5-core/tests/_utils/memory'; import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset'; import { assertCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils'; +import { removeEditorBodyOrphans } from '@ckeditor/ckeditor5-core/tests/_utils/cleanup'; const editorData = '

foo bar

'; @@ -187,17 +188,10 @@ describe( 'DecoupledEditor', () => { } ) .then( () => { - removeEditorDom(); + removeEditorBodyOrphans(); } ) .then( done ) .catch( 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( 'throws error if it is initialized in textarea', done => {