8
0
فهرست منبع

Moved more files to ckeditor5.

Piotrek Koszuliński 9 سال پیش
والد
کامیت
d6b300e4de

+ 0 - 58
packages/ckeditor5-engine/tests/_utils-tests/utils.js

@@ -1,58 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-import testUtils from '/tests/_utils/utils.js';
-import moduleTestUtils from '/tests/_utils/module.js';
-import coreTestUtils from '/tests/core/_utils/utils.js';
-import Creator from '/ckeditor5/core/creator.js';
-
-let createFn3 = () => {};
-let destroyFn3 = () => {};
-
-testUtils.createSinonSandbox();
-
-coreTestUtils.defineEditorCreatorMock( 'test1' );
-coreTestUtils.defineEditorCreatorMock( 'test2', {
-	foo: 1,
-	bar: 2
-} );
-coreTestUtils.defineEditorCreatorMock( 'test3', {
-	create: createFn3,
-	destroy: destroyFn3
-} );
-
-const modules = moduleTestUtils.require( {
-	testCreator1: 'creator-test1/creator-test1',
-	testCreator2: 'creator-test2/creator-test2',
-	testCreator3: 'creator-test3/creator-test3'
-} );
-
-///////////////////
-
-let TestCreator1, TestCreator2, TestCreator3;
-
-before( () => {
-	TestCreator1 = modules.testCreator1;
-	TestCreator2 = modules.testCreator2;
-	TestCreator3 = modules.testCreator3;
-} );
-
-describe( 'coreTestUtils.defineEditorCreatorMock()', () => {
-	it( 'should register all creators', () => {
-		expect( TestCreator1.prototype ).to.be.instanceof( Creator );
-		expect( TestCreator2.prototype ).to.be.instanceof( Creator );
-		expect( TestCreator3.prototype ).to.be.instanceof( Creator );
-	} );
-
-	it( 'should copy properties from the second argument', () => {
-		expect( TestCreator2.prototype ).to.have.property( 'foo', 1 );
-		expect( TestCreator2.prototype ).to.have.property( 'bar', 2 );
-
-		expect( TestCreator3.prototype ).to.have.property( 'create', createFn3 );
-		expect( TestCreator3.prototype ).to.have.property( 'destroy', destroyFn3 );
-	} );
-} );

+ 0 - 37
packages/ckeditor5-engine/tests/_utils/utils.js

@@ -1,37 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-import moduleUtils from '/tests/_utils/module.js';
-
-const utils = {
-	/**
-	 * Defines CKEditor plugin which is a mock of an editor creator.
-	 *
-	 * The mocked creator is available under:
-	 *
-	 *		editor.plugins.get( 'creator-thename' );
-	 *
-	 * @param {String} creatorName Name of the creator.
-	 * @param {Object} [proto] Prototype of the creator. Properties from the proto param will
-	 * be copied to the prototype of the creator.
-	 */
-	defineEditorCreatorMock( creatorName, proto ) {
-		moduleUtils.define( 'creator-' + creatorName, [ 'core/creator' ], ( Creator ) => {
-			class TestCreator extends Creator {}
-
-			if ( proto ) {
-				for ( let propName in proto ) {
-					TestCreator.prototype[ propName ] = proto[ propName ];
-				}
-			}
-
-			return TestCreator;
-		} );
-	}
-};
-
-export default utils;

+ 0 - 252
packages/ckeditor5-engine/tests/command/attributecommand.js

@@ -1,252 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-import Editor from '/ckeditor5/core/editor.js';
-import AttributeCommand from '/ckeditor5/core/command/attributecommand.js';
-import Text from '/ckeditor5/core/treemodel/text.js';
-import Range from '/ckeditor5/core/treemodel/range.js';
-import Position from '/ckeditor5/core/treemodel/position.js';
-import Element from '/ckeditor5/core/treemodel/element.js';
-
-let element, editor, command, modelDoc, root;
-
-const attrKey = 'bold';
-
-beforeEach( () => {
-	element = document.createElement( 'div' );
-	document.body.appendChild( element );
-
-	editor = new Editor( element );
-	modelDoc = editor.document;
-	root = modelDoc.createRoot( 'root', 'div' );
-
-	command = new AttributeCommand( editor, attrKey );
-
-	modelDoc.schema.registerItem( 'div', '$block' );
-	modelDoc.schema.registerItem( 'p', '$block' );
-	modelDoc.schema.registerItem( 'img', '$inline' );
-
-	// Allow block in "root" (DIV)
-	modelDoc.schema.allow( { name: '$block', inside: 'div' } );
-
-	// Bold text is allowed only in P.
-	modelDoc.schema.allow( { name: '$text', attribute: 'bold', inside: 'p' } );
-	modelDoc.schema.allow( { name: 'p', attribute: 'bold', inside: 'div' } );
-
-	// Disallow bold on image.
-	modelDoc.schema.disallow( { name: 'img', attribute: 'bold', inside: 'div' } );
-} );
-
-describe( 'value', () => {
-	it( 'should be set to true or false basing on selection attribute', () => {
-		modelDoc.selection.setAttribute( attrKey, true );
-		expect( command.value ).to.be.true;
-
-		modelDoc.selection.removeAttribute( attrKey );
-		expect( command.value ).to.be.false;
-	} );
-} );
-
-describe( '_doExecute', () => {
-	let p;
-
-	beforeEach( () => {
-		let attrs = {};
-		attrs[ attrKey ] = true;
-
-		root.insertChildren( 0, [ new Element( 'p', [] , [ 'abc', new Text( 'foobar', attrs ), 'xyz' ] ), new Element( 'p' ) ] );
-		p = root.getChild( 0 );
-	} );
-
-	it( 'should add attribute on selected nodes if the command value was false', () => {
-		modelDoc.selection.addRange( new Range( new Position( root, [ 0, 1 ] ), new Position( root, [ 0, 5 ] ) ) );
-
-		expect( command.value ).to.be.false;
-
-		command._doExecute();
-
-		expect( command.value ).to.be.true;
-		expect( p.getChild( 1 ).hasAttribute( attrKey ) ).to.be.true;
-		expect( p.getChild( 2 ).hasAttribute( attrKey ) ).to.be.true;
-	} );
-
-	it( 'should remove attribute from selected nodes if the command value was true', () => {
-		modelDoc.selection.addRange( new Range( new Position( root, [ 0, 3 ] ), new Position( root, [ 0, 6 ] ) ) );
-
-		expect( command.value ).to.be.true;
-
-		command._doExecute();
-
-		expect( command.value ).to.be.false;
-		expect( p.getChild( 3 ).hasAttribute( attrKey ) ).to.be.false;
-		expect( p.getChild( 4 ).hasAttribute( attrKey ) ).to.be.false;
-		expect( p.getChild( 5 ).hasAttribute( attrKey ) ).to.be.false;
-	} );
-
-	it( 'should add attribute on selected nodes if execute parameter was set to true', () => {
-		modelDoc.selection.addRange( new Range( new Position( root, [ 0, 7 ] ), new Position( root, [ 0, 10 ] ) ) );
-
-		expect( command.value ).to.be.true;
-
-		command._doExecute( true );
-
-		expect( command.value ).to.be.true;
-		expect( p.getChild( 9 ).hasAttribute( attrKey ) ).to.be.true;
-	} );
-
-	it( 'should remove attribute on selected nodes if execute parameter was set to false', () => {
-		modelDoc.selection.addRange( new Range( new Position( root, [ 0, 1 ] ), new Position( root, [ 0, 5 ] ) ) );
-
-		expect( command.value ).to.be.false;
-
-		command._doExecute( false );
-
-		expect( command.value ).to.be.false;
-		expect( p.getChild( 3 ).hasAttribute( attrKey ) ).to.be.false;
-		expect( p.getChild( 4 ).hasAttribute( attrKey ) ).to.be.false;
-	} );
-
-	it( 'should change selection attribute if selection is collapsed in non-empty parent', () => {
-		modelDoc.selection.addRange( new Range( new Position( root, [ 0, 1 ] ), new Position( root, [ 0, 1 ] ) ) );
-
-		expect( command.value ).to.be.false;
-
-		command._doExecute();
-
-		expect( command.value ).to.be.true;
-		expect( modelDoc.selection.hasAttribute( 'bold' ) ).to.be.true;
-
-		command._doExecute();
-
-		expect( command.value ).to.be.false;
-		expect( modelDoc.selection.hasAttribute( 'bold' ) ).to.be.false;
-	} );
-
-	it( 'should not store attribute change on selection if selection is collapsed in non-empty parent', () => {
-		modelDoc.selection.addRange( new Range( new Position( root, [ 0, 1 ] ), new Position( root, [ 0, 1 ] ) ) );
-		command._doExecute();
-
-		// It should not save that bold was executed at position ( root, [ 0, 1 ] ).
-
-		// Simulate clicking right arrow key by changing selection ranges.
-		modelDoc.selection.setRanges( [ new Range( new Position( root, [ 0, 2 ] ), new Position( root, [ 0, 2 ] ) ) ] );
-
-		// Get back to previous selection.
-		modelDoc.selection.setRanges( [ new Range( new Position( root, [ 0, 1 ] ), new Position( root, [ 0, 1 ] ) ) ] );
-
-		expect( command.value ).to.be.false;
-	} );
-
-	it( 'should change selection attribute and store it if selection is collapsed in empty parent', () => {
-		modelDoc.selection.setRanges( [ new Range( new Position( root, [ 1, 0 ] ), new Position( root, [ 1, 0 ] ) ) ] );
-
-		expect( command.value ).to.be.false;
-
-		command._doExecute();
-
-		expect( command.value ).to.be.true;
-		expect( modelDoc.selection.hasAttribute( 'bold' ) ).to.be.true;
-
-		// Attribute should be stored.
-		// Simulate clicking somewhere else in the editor.
-		modelDoc.selection.setRanges( [ new Range( new Position( root, [ 0, 2 ] ), new Position( root, [ 0, 2 ] ) ) ] );
-
-		expect( command.value ).to.be.false;
-
-		// Go back to where attribute was stored.
-		modelDoc.selection.setRanges( [ new Range( new Position( root, [ 1, 0 ] ), new Position( root, [ 1, 0 ] ) ) ] );
-
-		// Attribute should be restored.
-		expect( command.value ).to.be.true;
-
-		command._doExecute();
-
-		expect( command.value ).to.be.false;
-		expect( modelDoc.selection.hasAttribute( 'bold' ) ).to.be.false;
-	} );
-
-	it( 'should not apply attribute change where it would invalid schema', () => {
-		p.insertChildren( 3, new Element( 'image' ) );
-		p.insertChildren( 12, new Element( 'image' ) );
-		modelDoc.selection.setRanges( [ new Range( new Position( root, [ 0, 2 ] ), new Position( root, [ 0, 13 ] ) ) ] );
-
-		expect( command.isEnabled ).to.be.true;
-
-		command._doExecute();
-
-		let expectedHas = [ 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 ];
-
-		for ( let i = 0; i < expectedHas.length; i++ ) {
-			expect( p.getChild( i ).hasAttribute( attrKey ) ).to.equal( !!expectedHas[ i ] );
-		}
-	} );
-} );
-
-describe( '_checkEnabled', () => {
-	beforeEach( () => {
-		root.insertChildren( 0, [
-			new Element( 'p', [], [
-				'foo',
-				new Element( 'img' ),
-				new Element( 'img' ),
-				'bar'
-			] ),
-			new Element( 'div' ),
-			new Element( 'p' )
-		] );
-	} );
-
-	describe( 'when selection is collapsed', () => {
-		it( 'should return true if characters with the attribute can be placed at caret position', () => {
-			modelDoc.selection.setRanges( [ new Range( new Position( root, [ 0, 1 ] ), new Position( root, [ 0, 1 ] ) ) ] );
-			expect( command._checkEnabled() ).to.be.true;
-		} );
-
-		it( 'should return false if characters with the attribute cannot be placed at caret position', () => {
-			modelDoc.selection.setRanges( [ new Range( new Position( root, [ 1, 0 ] ), new Position( root, [ 1, 0 ] ) ) ] );
-			expect( command._checkEnabled() ).to.be.false;
-
-			modelDoc.selection.setRanges( [ new Range( new Position( root, [ 2 ] ), new Position( root, [ 2 ] ) ) ] );
-			expect( command._checkEnabled() ).to.be.false;
-		} );
-	} );
-
-	describe( 'when selection is not collapsed', () => {
-		it( 'should return true if there is at least one node in selection that can have the attribute', () => {
-			// Simple selection on a few characters.
-			modelDoc.selection.setRanges( [ new Range( new Position( root, [ 0, 0 ] ), new Position( root, [ 0, 3 ] ) ) ] );
-			expect( command._checkEnabled() ).to.be.true;
-
-			// Selection spans over characters but also include nodes that can't have attribute.
-			modelDoc.selection.setRanges( [ new Range( new Position( root, [ 0, 2 ] ), new Position( root, [ 0, 6 ] ) ) ] );
-			expect( command._checkEnabled() ).to.be.true;
-
-			// Selection on whole root content. Characters in P can have an attribute so it's valid.
-			modelDoc.selection.setRanges( [ new Range( new Position( root, [ 0 ] ), new Position( root, [ 3 ] ) ) ] );
-			expect( command._checkEnabled() ).to.be.true;
-
-			// Selection on empty P. P can have the attribute.
-			modelDoc.selection.setRanges( [ new Range( new Position( root, [ 2 ] ), new Position( root, [ 3 ] ) ) ] );
-			expect( command._checkEnabled() ).to.be.true;
-		} );
-
-		it( 'should return false if there are no nodes in selection that can have the attribute', () => {
-			// Selection on DIV which can't have bold text.
-			modelDoc.selection.setRanges( [ new Range( new Position( root, [ 1 ] ), new Position( root, [ 2 ] ) ) ] );
-			expect( command._checkEnabled() ).to.be.false;
-
-			// Selection on two images which can't be bold.
-			modelDoc.selection.setRanges( [ new Range( new Position( root, [ 0, 3 ] ), new Position( root, [ 0, 5 ] ) ) ] );
-			expect( command._checkEnabled() ).to.be.false;
-		} );
-	} );
-
-	it( 'should return false if selection has no ranges', () => {
-		modelDoc.selection.removeAllRanges();
-		expect( command._checkEnabled() ).to.be.false;
-	} );
-} );

+ 0 - 149
packages/ckeditor5-engine/tests/command/command.js

@@ -1,149 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-import Editor from '/ckeditor5/core/editor.js';
-import Command from '/ckeditor5/core/command/command.js';
-
-let element, editor, command;
-
-class CommandWithSchema extends Command {
-	constructor( editor, schemaValid ) {
-		super( editor );
-
-		this.schemaValid = schemaValid;
-	}
-
-	_checkEnabled() {
-		return this.schemaValid;
-	}
-}
-
-beforeEach( () => {
-	element = document.createElement( 'div' );
-	document.body.appendChild( element );
-
-	editor = new Editor( element );
-	command = new Command( editor );
-} );
-
-describe( 'constructor', () => {
-	it( 'should create a new command instance, that is enabled and bound to given editor', () => {
-		expect( command ).to.have.property( 'editor' ).equal( editor );
-		expect( command.isEnabled ).to.be.true;
-	} );
-
-	it( 'Command should have _doExecute method', () => {
-		expect( () => {
-			command._doExecute();
-		} ).not.to.throw;
-	} );
-
-	it( 'should add listener to its refreshState event if checkSchema method is present', () => {
-		expect( command._checkEnabled ).to.be.undefined;
-
-		command._checkEnabled = sinon.spy();
-		command.refreshState();
-
-		expect( command._checkEnabled.called ).to.be.false;
-
-		let newCommand = new CommandWithSchema( editor, true );
-		sinon.spy( newCommand, '_checkEnabled' );
-
-		newCommand.refreshState();
-
-		expect( newCommand._checkEnabled.calledOnce ).to.be.true;
-	} );
-} );
-
-describe( 'refreshState', () => {
-	it( 'should fire refreshState event', () => {
-		let spy = sinon.spy();
-
-		command.on( 'refreshState', spy );
-		command.refreshState();
-
-		expect( spy.called ).to.be.true;
-	} );
-
-	it( 'should set isEnabled property to the value passed by object-reference', () => {
-		command.on( 'refreshState', ( evt, data ) => {
-			data.isEnabled = true;
-		} );
-
-		expect( command.isEnabled ).to.be.true;
-	} );
-
-	it( 'should set isEnabled to false if _checkEnabled returns false', () => {
-		let disabledCommand = new CommandWithSchema( editor, false );
-
-		disabledCommand.refreshState();
-
-		expect( disabledCommand.isEnabled ).to.be.false;
-	} );
-} );
-
-describe( 'disable', () => {
-	it( 'should make command disabled', () => {
-		command._disable();
-
-		expect( command.isEnabled ).to.be.false;
-	} );
-
-	it( 'should not make command disabled if there is a high-priority listener forcing command to be enabled', () => {
-		command.on( 'refreshState', ( evt ) => {
-			evt.stop();
-
-			return true;
-		}, command, 1 );
-
-		command._disable();
-
-		expect( command.isEnabled ).to.be.true;
-	} );
-} );
-
-describe( 'enable', () => {
-	it( 'should make command enabled if it was previously disabled by disable()', () => {
-		command._disable();
-		command._enable();
-
-		expect( command.isEnabled ).to.be.true;
-	} );
-
-	it( 'should not make command enabled if there are other listeners disabling it', () => {
-		command._disable();
-
-		command.on( 'refreshState', ( evt, data ) => {
-			data.isEnabled = false;
-		} );
-
-		command.refreshState();
-		command._enable();
-
-		expect( command.isEnabled ).to.be.false;
-	} );
-} );
-
-describe( '_execute', () => {
-	it( 'should not execute command if it is disabled', () => {
-		command._disable();
-
-		sinon.spy( command, '_doExecute' );
-
-		command._execute();
-
-		expect( command._doExecute.called ).to.be.false;
-	} );
-
-	it( 'should execute command if it is enabled', () => {
-		sinon.spy( command, '_doExecute' );
-
-		command._execute();
-
-		expect( command._doExecute.called ).to.be.true;
-	} );
-} );

+ 0 - 212
packages/ckeditor5-engine/tests/editor/creator.js

@@ -1,212 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-/* bender-tags: editor, creator */
-
-import moduleUtils from '/tests/_utils/module.js';
-import testUtils from '/tests/_utils/utils.js';
-import coreTestUtils from '/tests/core/_utils/utils.js';
-import Editor from '/ckeditor5/core/editor.js';
-import Creator from '/ckeditor5/core/creator.js';
-import CKEditorError from '/ckeditor5/utils/ckeditorerror.js';
-
-let editor, element;
-
-function initEditor( config ) {
-	element = document.createElement( 'div' );
-	document.body.appendChild( element );
-
-	editor = new Editor( element, config );
-
-	return editor.init();
-}
-
-testUtils.createSinonSandbox();
-
-before( () => {
-	coreTestUtils.defineEditorCreatorMock( 'test1', {
-		create: sinon.spy(),
-		destroy: sinon.spy()
-	} );
-
-	coreTestUtils.defineEditorCreatorMock( 'test-throw-on-many1' );
-	coreTestUtils.defineEditorCreatorMock( 'test-throw-on-many2' );
-
-	coreTestUtils.defineEditorCreatorMock( 'test-config1', {
-		create: sinon.spy()
-	} );
-	coreTestUtils.defineEditorCreatorMock( 'test-config2', {
-		create: sinon.spy()
-	} );
-
-	moduleUtils.define( 'test3', [ 'core/plugin' ], ( Plugin ) => {
-		return class extends Plugin {};
-	} );
-
-	moduleUtils.define( 'creator-async-create', [ 'core/creator' ], ( Creator ) => {
-		return class extends Creator {
-			create() {
-				return new Promise( ( resolve, reject ) => {
-					reject( new Error( 'Catch me - create.' ) );
-				} );
-			}
-
-			destroy() {}
-		};
-	} );
-
-	moduleUtils.define( 'creator-async-destroy', [ 'core/creator' ], ( Creator ) => {
-		return class extends Creator {
-			create() {}
-
-			destroy() {
-				return new Promise( ( resolve, reject ) => {
-					reject( new Error( 'Catch me - destroy.' ) );
-				} );
-			}
-		};
-	} );
-
-	moduleUtils.define( 'creator-destroy-order', [ 'core/creator' ], ( Creator ) => {
-		return class extends Creator {
-			create() {}
-
-			destroy() {
-				editor._elementInsideCreatorDestroy = this.editor.element;
-				editor._destroyOrder.push( 'creator' );
-			}
-		};
-	} );
-} );
-
-afterEach( () => {
-	editor = null; // To make sure we're using the freshly inited editor.
-} );
-
-///////////////////
-
-describe( 'init', () => {
-	it( 'should instantiate the creator and call create()', () => {
-		return initEditor( {
-				creator: 'creator-test1'
-			} )
-			.then( () => {
-				let creator = editor.plugins.get( 'creator-test1' );
-
-				expect( creator ).to.be.instanceof( Creator );
-
-				// The create method has been called.
-				sinon.assert.calledOnce( creator.create );
-			} );
-	} );
-
-	it( 'should throw if creator is not defined', () => {
-		return initEditor( {} )
-			.then( () => {
-				throw new Error( 'This should not be executed.' );
-			} )
-			.catch( ( err ) => {
-				expect( err ).to.be.instanceof( CKEditorError );
-				expect( err.message ).to.match( /^editor-undefined-creator:/ );
-			} );
-	} );
-
-	it( 'should use the creator specified in config.creator', () => {
-		return initEditor( {
-				creator: 'creator-test-config2',
-				features: [ 'creator-test-config1', 'creator-test-config2' ],
-			} )
-			.then( () => {
-				let creator1 = editor.plugins.get( 'creator-test-config1' );
-				let creator2 = editor.plugins.get( 'creator-test-config2' );
-
-				sinon.assert.calledOnce( creator2.create );
-				sinon.assert.notCalled( creator1.create );
-			} );
-	} );
-
-	it( 'should throw an error if the creator doesn\'t exist', () => {
-		return initEditor( {
-				creator: 'bad'
-			} )
-			.then( () => {
-				throw new Error( 'This should not be executed.' );
-			} )
-			.catch( ( err ) => {
-				// It's the Require.JS error.
-				expect( err ).to.be.an.instanceof( Error );
-				expect( err.message ).to.match( /^Script error for/ );
-			} );
-	} );
-
-	it( 'should chain the promise from the creator (enables async creators)', () => {
-		return initEditor( {
-				creator: 'creator-async-create'
-			} )
-			.then( () => {
-				throw new Error( 'This should not be executed.' );
-			} )
-			.catch( ( err ) => {
-				// Unfortunately fake timers don't work with promises, so throwing in the creator's create()
-				// seems to be the only way to test that the promise chain isn't broken.
-				expect( err ).to.have.property( 'message', 'Catch me - create.' );
-			} );
-	} );
-} );
-
-describe( 'destroy', () => {
-	it( 'should call "destroy" on the creator', () => {
-		let creator1;
-
-		return initEditor( {
-				creator: 'creator-test1'
-			} )
-			.then( () => {
-				creator1 = editor.plugins.get( 'creator-test1' );
-
-				return editor.destroy();
-			} )
-			.then( () => {
-				sinon.assert.calledOnce( creator1.destroy );
-			} );
-	} );
-
-	it( 'should chain the promise from the creator (enables async creators)', () => {
-		return initEditor( {
-				creator: 'creator-async-destroy'
-			} )
-			.then( () => {
-				return editor.destroy();
-			} )
-			.then( () => {
-				throw new Error( 'This should not be executed.' );
-			} )
-			.catch( ( err ) => {
-				// Unfortunately fake timers don't work with promises, so throwing in the creator's destroy()
-				// seems to be the only way to test that the promise chain isn't broken.
-				expect( err ).to.have.property( 'message', 'Catch me - destroy.' );
-			} );
-	} );
-
-	it( 'should do things in the correct order', () => {
-		return initEditor( {
-				creator: 'creator-destroy-order'
-			} )
-			.then( () => {
-				editor._destroyOrder = [];
-				editor.on( 'destroy', () => {
-					editor._destroyOrder.push( 'event' );
-				} );
-
-				return editor.destroy();
-			} )
-			.then( () => {
-				expect( editor._elementInsideCreatorDestroy ).to.not.be.undefined;
-				expect( editor._destroyOrder ).to.deep.equal( [ 'event', 'creator' ] );
-			} );
-	} );
-} );

+ 0 - 280
packages/ckeditor5-engine/tests/editor/editor.js

@@ -1,280 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-/* bender-tags: editor */
-
-import moduleUtils from '/tests/_utils/module.js';
-import coreTestUtils from '/tests/core/_utils/utils.js';
-import Editor from '/ckeditor5/core/editor.js';
-import EditorConfig from '/ckeditor5/core/editorconfig.js';
-import Plugin from '/ckeditor5/core/plugin.js';
-import Command from '/ckeditor5/core/command/command.js';
-import Locale from '/ckeditor5/utils/locale.js';
-import CKEditorError from '/ckeditor5/utils/ckeditorerror.js';
-
-const pluginClasses = {};
-let element;
-
-before( () => {
-	// Define fake plugins to be used in tests.
-	coreTestUtils.defineEditorCreatorMock( 'test', {
-		init: sinon.spy().named( 'creator-test' )
-	} );
-
-	pluginDefinition( 'A' );
-	pluginDefinition( 'B' );
-	pluginDefinition( 'C', [ 'B' ] );
-	pluginDefinition( 'D', [ 'C' ] );
-} );
-
-beforeEach( () => {
-	element = document.createElement( 'div' );
-	document.body.appendChild( element );
-} );
-
-///////////////////
-
-describe( 'constructor', () => {
-	it( 'should create a new editor instance', () => {
-		const editor = new Editor( element );
-
-		expect( editor ).to.have.property( 'element' ).to.equal( element );
-	} );
-} );
-
-describe( 'config', () => {
-	it( 'should be an instance of EditorConfig', () => {
-		const editor = new Editor( element );
-
-		expect( editor.config ).to.be.an.instanceof( EditorConfig );
-	} );
-} );
-
-describe( 'locale', () => {
-	it( 'is instantiated and t() is exposed', () => {
-		const editor = new Editor( element );
-
-		expect( editor.locale ).to.be.instanceof( Locale );
-		expect( editor.t ).to.equal( editor.locale.t );
-	} );
-
-	it( 'is configured with the config.lang', () => {
-		const editor = new Editor( element, { lang: 'pl' } );
-
-		expect( editor.locale.lang ).to.equal( 'pl' );
-	} );
-} );
-
-describe( 'init', () => {
-	it( 'should return a promise that resolves properly', () => {
-		const editor = new Editor( element, {
-			creator: 'creator-test'
-		} );
-
-		let promise = editor.init();
-
-		expect( promise ).to.be.an.instanceof( Promise );
-
-		return promise;
-	} );
-
-	it( 'should load features and creator', () => {
-		const editor = new Editor( element, {
-			features: [ 'A', 'B' ],
-			creator: 'creator-test'
-		} );
-
-		expect( getPlugins( editor ) ).to.be.empty;
-
-		return editor.init().then( () => {
-			expect( getPlugins( editor ).length ).to.equal( 3 );
-
-			expect( editor.plugins.get( 'A' ) ).to.be.an.instanceof( Plugin );
-			expect( editor.plugins.get( 'B' ) ).to.be.an.instanceof( Plugin );
-			expect( editor.plugins.get( 'creator-test' ) ).to.be.an.instanceof( Plugin );
-		} );
-	} );
-
-	it( 'should load features passed as a string', () => {
-		const editor = new Editor( element, {
-			features: 'A,B',
-			creator: 'creator-test'
-		} );
-
-		expect( getPlugins( editor ) ).to.be.empty;
-
-		return editor.init().then( () => {
-			expect( getPlugins( editor ).length ).to.equal( 3 );
-
-			expect( editor.plugins.get( 'A' ) ).to.be.an.instanceof( Plugin );
-			expect( editor.plugins.get( 'B' ) ).to.be.an.instanceof( Plugin );
-		} );
-	} );
-
-	it( 'should initialize plugins in the right order', () => {
-		const editor = new Editor( element, {
-			features: [ 'A', 'D' ],
-			creator: 'creator-test'
-		} );
-
-		return editor.init().then( () => {
-			sinon.assert.callOrder(
-				editor.plugins.get( 'creator-test' ).init,
-				editor.plugins.get( pluginClasses.A ).init,
-				editor.plugins.get( pluginClasses.B ).init,
-				editor.plugins.get( pluginClasses.C ).init,
-				editor.plugins.get( pluginClasses.D ).init
-			);
-		} );
-	} );
-
-	it( 'should initialize plugins in the right order, waiting for asynchronous ones', () => {
-		class PluginAsync extends Plugin {}
-		const asyncSpy = sinon.spy().named( 'async-call-spy' );
-
-		// Synchronous plugin that depends on an asynchronous one.
-		pluginDefinition( 'sync', [ 'async' ] );
-
-		moduleUtils.define( 'async', () => {
-			PluginAsync.prototype.init = sinon.spy( () => {
-				return new Promise( ( resolve ) => {
-					setTimeout( () => {
-						asyncSpy();
-						resolve();
-					}, 0 );
-				} );
-			} );
-
-			return PluginAsync;
-		} );
-
-		const editor = new Editor( element, {
-			features: [ 'A', 'sync' ],
-			creator: 'creator-test'
-		} );
-
-		return editor.init().then( () => {
-			sinon.assert.callOrder(
-				editor.plugins.get( 'creator-test' ).init,
-				editor.plugins.get( pluginClasses.A ).init,
-				editor.plugins.get( PluginAsync ).init,
-				// This one is called with delay by the async init.
-				asyncSpy,
-				editor.plugins.get( pluginClasses.sync ).init
-			);
-		} );
-	} );
-} );
-
-describe( 'plugins', () => {
-	it( 'should be empty on new editor', () => {
-		const editor = new Editor( element );
-
-		expect( getPlugins( editor ) ).to.be.empty;
-	} );
-} );
-
-describe( 'destroy', () => {
-	it( 'should fire "destroy"', () => {
-		const editor = new Editor( element );
-		let spy = sinon.spy();
-
-		editor.on( 'destroy', spy );
-
-		return editor.destroy().then( () => {
-			sinon.assert.called( spy );
-		} );
-	} );
-
-	it( 'should delete the "element" property', () => {
-		const editor = new Editor( element );
-
-		return editor.destroy().then( () => {
-			expect( editor ).to.not.have.property( 'element' );
-		} );
-	} );
-} );
-
-describe( 'execute', () => {
-	it( 'should execute specified command', () => {
-		const editor = new Editor( element );
-
-		let command = new Command( editor );
-		sinon.spy( command, '_execute' );
-
-		editor.commands.set( 'command_name', command );
-		editor.execute( 'command_name' );
-
-		expect( command._execute.calledOnce ).to.be.true;
-	} );
-
-	it( 'should throw an error if specified command has not been added', () => {
-		const editor = new Editor( element );
-
-		expect( () => {
-			editor.execute( 'command' );
-		} ).to.throw( CKEditorError, /editor-command-not-found/ );
-	} );
-} );
-
-describe( 'setData', () => {
-	it( 'should set data on the editable', () => {
-		const editor = new Editor( element );
-		editor.editable = {
-			setData: sinon.spy()
-		};
-
-		editor.setData( 'foo' );
-
-		expect( editor.editable.setData.calledOnce ).to.be.true;
-		expect( editor.editable.setData.args[ 0 ][ 0 ] ).to.equal( 'foo' );
-	} );
-
-	it( 'should get data from the editable', () => {
-		const editor = new Editor( element );
-		editor.editable = {
-			getData() {
-				return 'bar';
-			}
-		};
-
-		expect( editor.getData() ).to.equal( 'bar' );
-	} );
-} );
-
-/**
- * @param {String} name Name of the plugin.
- * @param {String[]} deps Dependencies of the plugin (only other plugins).
- */
-function pluginDefinition( name, deps ) {
-	moduleUtils.define( name, deps || [], function() {
-		class NewPlugin extends Plugin {}
-
-		NewPlugin.prototype.init = sinon.spy().named( name );
-		NewPlugin.requires = Array.from( arguments );
-
-		pluginClasses[ name ] = NewPlugin;
-
-		return NewPlugin;
-	} );
-}
-
-/**
- * Returns an array of loaded plugins.
- */
-function getPlugins( editor ) {
-	const plugins = [];
-
-	for ( let entry of editor.plugins ) {
-		// Keep only plugins kept under their classes.
-		if ( typeof entry[ 0 ] == 'function' ) {
-			plugins.push( entry[ 1 ] );
-		}
-	}
-
-	return plugins;
-}