From b5e00dd1627072be96935c5cb0a150db1d149ee4 Mon Sep 17 00:00:00 2001 From: Szymon Cofalik Date: Wed, 16 Nov 2016 09:23:18 +0100 Subject: [PATCH] Tests: added additional test for EditingController#destroy. --- tests/controller/editingcontroller.js | 31 ++++++++++++++++++--------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/tests/controller/editingcontroller.js b/tests/controller/editingcontroller.js index 89f5a6740..19e1293b4 100644 --- a/tests/controller/editingcontroller.js +++ b/tests/controller/editingcontroller.js @@ -28,16 +28,18 @@ import { getData as getViewData } from 'ckeditor5/engine/dev-utils/view.js'; describe( 'EditingController', () => { describe( 'constructor()', () => { - it( 'should create controller with properties', () => { - const model = new ModelDocument(); - const editing = new EditingController( model ); + let model, editing; + + beforeEach( () => { + model = new ModelDocument(); + editing = new EditingController( model ); + } ); + it( 'should create controller with properties', () => { expect( editing ).to.have.property( 'model' ).that.equals( model ); expect( editing ).to.have.property( 'view' ).that.is.instanceof( ViewDocument ); expect( editing ).to.have.property( 'mapper' ).that.is.instanceof( Mapper ); expect( editing ).to.have.property( 'modelToView' ).that.is.instanceof( ModelConversionDispatcher ); - - editing.destroy(); } ); } ); @@ -52,10 +54,6 @@ describe( 'EditingController', () => { editing = new EditingController( model ); } ); - afterEach( () => { - editing.destroy(); - } ); - it( 'should create root', () => { const domRoot = createElement( document, 'div', null, createElement( document, 'p' ) ); @@ -130,7 +128,6 @@ describe( 'EditingController', () => { after( () => { document.body.removeChild( domRoot ); listener.stopListening(); - editing.destroy(); } ); beforeEach( () => { @@ -277,8 +274,22 @@ describe( 'EditingController', () => { } ); expect( spy.called ).to.be.false; + } ); + + it( 'should destroy view', () => { + let model, editing; + + model = new ModelDocument(); + model.createRoot(); + model.schema.registerItem( 'paragraph', '$block' ); + + editing = new EditingController( model ); + + const spy = sinon.spy( editing.view, 'destroy' ); editing.destroy(); + + expect( spy.called ).to.be.true; } ); } ); } );