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

Commit

Permalink
Internal: Updated the usage of UI components which are now driven by …
Browse files Browse the repository at this point in the history
…synchronous initialization and destruction (see https://github.com/ckeditor/ckeditor5-ui/issues/225).
  • Loading branch information
Reinmar committed Jul 5, 2017
2 parents e00a282 + b3affc8 commit 4d768df
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 24 deletions.
23 changes: 5 additions & 18 deletions tests/_utils-tests/classictesteditorui.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,21 @@ describe( 'ClassicTestEditorUI', () => {
} );

describe( 'init()', () => {
it( 'returns a promise', () => {
expect( ui.init() ).to.be.instanceof( Promise );
} );

it( 'initializes the #view', () => {
const spy = sinon.spy( view, 'init' );

return ui.init().then( () => {
sinon.assert.calledOnce( spy );
} );
ui.init();
sinon.assert.calledOnce( spy );
} );
} );

describe( 'destroy()', () => {
it( 'returns a promise', () => {
return ui.init().then( () => {
expect( ui.destroy() ).to.be.instanceof( Promise );
} );
} );

it( 'destroys the #view', () => {
const spy = sinon.spy( view, 'destroy' );

return ui.init()
.then( () => ui.destroy() )
.then( () => {
sinon.assert.calledOnce( spy );
} );
ui.init();
ui.destroy();
sinon.assert.calledOnce( spy );
} );
} );
} );
10 changes: 6 additions & 4 deletions tests/_utils/classictesteditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export default class ClassicTestEditor extends StandardEditor {
*/
destroy() {
this._elementReplacer.restore();
this.ui.destroy();

return super.destroy()
.then( () => this.ui.destroy() );
return super.destroy();
}

/**
Expand All @@ -57,8 +57,10 @@ export default class ClassicTestEditor extends StandardEditor {
resolve(
editor.initPlugins()
.then( () => editor._elementReplacer.replace( element, editor.ui.view.element ) )
.then( () => editor.ui.init() )
.then( () => editor.fire( 'uiReady' ) )
.then( () => {
editor.ui.init();
editor.fire( 'uiReady' );
} )
.then( () => editor.editing.view.attachDomRoot( editor.ui.view.editableElement ) )
.then( () => editor.loadDataFromEditorElement() )
.then( () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/_utils/classictesteditorui.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default class ClassicTestEditorUI {
* @returns {Promise} A Promise resolved when the initialization process is finished.
*/
init() {
return this.view.init();
this.view.init();
}

/**
Expand All @@ -67,6 +67,6 @@ export default class ClassicTestEditorUI {
* @returns {Promise} A Promise resolved when the destruction process is finished.
*/
destroy() {
return this.view.destroy();
this.view.destroy();
}
}

0 comments on commit 4d768df

Please sign in to comment.