Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #10 from ckeditor/i/6002
Browse files Browse the repository at this point in the history
Tests: Fixed tests leaking editor instances / DOM elements. See ckeditor/ckeditor5#6002.
  • Loading branch information
pomek committed Jan 7, 2020
2 parents 306f6e8 + 090e184 commit 58f7cac
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
10 changes: 7 additions & 3 deletions tests/specialcharactersarrows.js
Expand Up @@ -13,10 +13,10 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
describe( 'SpecialCharactersArrows', () => {
testUtils.createSinonSandbox();

let addItemsSpy, addItemsFirstCallArgs;
let editor, editorElement, addItemsSpy, addItemsFirstCallArgs;

beforeEach( () => {
const editorElement = document.createElement( 'div' );
editorElement = document.createElement( 'div' );

addItemsSpy = sinon.spy( SpecialCharacters.prototype, 'addItems' );

Expand All @@ -25,13 +25,17 @@ describe( 'SpecialCharactersArrows', () => {
.create( editorElement, {
plugins: [ SpecialCharacters, SpecialCharactersArrows ]
} )
.then( () => {
.then( newEditor => {
editor = newEditor;
addItemsFirstCallArgs = addItemsSpy.args[ 0 ];
} );
} );

afterEach( () => {
addItemsSpy.restore();

editorElement.remove();
return editor.destroy();
} );

it( 'adds new items', () => {
Expand Down
10 changes: 7 additions & 3 deletions tests/specialcharacterscurrency.js
Expand Up @@ -13,10 +13,10 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
describe( 'SpecialCharactersCurrency', () => {
testUtils.createSinonSandbox();

let addItemsSpy, addItemsFirstCallArgs;
let editor, editorElement, addItemsSpy, addItemsFirstCallArgs;

beforeEach( () => {
const editorElement = document.createElement( 'div' );
editorElement = document.createElement( 'div' );

addItemsSpy = sinon.spy( SpecialCharacters.prototype, 'addItems' );

Expand All @@ -25,13 +25,17 @@ describe( 'SpecialCharactersCurrency', () => {
.create( editorElement, {
plugins: [ SpecialCharacters, SpecialCharactersCurrency ]
} )
.then( () => {
.then( newEditor => {
editor = newEditor;
addItemsFirstCallArgs = addItemsSpy.args[ 0 ];
} );
} );

afterEach( () => {
addItemsSpy.restore();

editorElement.remove();
return editor.destroy();
} );

it( 'adds new items', () => {
Expand Down
10 changes: 7 additions & 3 deletions tests/specialcharacterslatin.js
Expand Up @@ -13,10 +13,10 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
describe( 'SpecialCharactersLatin', () => {
testUtils.createSinonSandbox();

let addItemsSpy, addItemsFirstCallArgs;
let editor, editorElement, addItemsSpy, addItemsFirstCallArgs;

beforeEach( () => {
const editorElement = document.createElement( 'div' );
editorElement = document.createElement( 'div' );

addItemsSpy = sinon.spy( SpecialCharacters.prototype, 'addItems' );

Expand All @@ -25,13 +25,17 @@ describe( 'SpecialCharactersLatin', () => {
.create( editorElement, {
plugins: [ SpecialCharacters, SpecialCharactersLatin ]
} )
.then( () => {
.then( newEditor => {
editor = newEditor;
addItemsFirstCallArgs = addItemsSpy.args[ 0 ];
} );
} );

afterEach( () => {
addItemsSpy.restore();

editorElement.remove();
return editor.destroy();
} );

it( 'adds new items', () => {
Expand Down
10 changes: 7 additions & 3 deletions tests/specialcharacterstext.js
Expand Up @@ -13,10 +13,10 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
describe( 'SpecialCharactersText', () => {
testUtils.createSinonSandbox();

let addItemsSpy, addItemsFirstCallArgs;
let editor, editorElement, addItemsSpy, addItemsFirstCallArgs;

beforeEach( () => {
const editorElement = document.createElement( 'div' );
editorElement = document.createElement( 'div' );

addItemsSpy = sinon.spy( SpecialCharacters.prototype, 'addItems' );

Expand All @@ -25,13 +25,17 @@ describe( 'SpecialCharactersText', () => {
.create( editorElement, {
plugins: [ SpecialCharacters, SpecialCharactersText ]
} )
.then( () => {
.then( newEditor => {
editor = newEditor;
addItemsFirstCallArgs = addItemsSpy.args[ 0 ];
} );
} );

afterEach( () => {
addItemsSpy.restore();

editorElement.remove();
return editor.destroy();
} );

it( 'adds new items', () => {
Expand Down

0 comments on commit 58f7cac

Please sign in to comment.