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

Commit

Permalink
Tests: added additional test for EditingController#destroy.
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed Nov 16, 2016
1 parent 9a10e12 commit b5e00dd
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions tests/controller/editingcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
} );
} );

Expand All @@ -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' ) );

Expand Down Expand Up @@ -130,7 +128,6 @@ describe( 'EditingController', () => {
after( () => {
document.body.removeChild( domRoot );
listener.stopListening();
editing.destroy();
} );

beforeEach( () => {
Expand Down Expand Up @@ -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;
} );
} );
} );

0 comments on commit b5e00dd

Please sign in to comment.