瀏覽代碼

Initial adjustments for porting tests to ES6 modules.

Piotrek Koszuliński 10 年之前
父節點
當前提交
8140b9a24d

+ 1 - 1
packages/ckeditor5-engine/src/editorconfig.js

@@ -5,7 +5,7 @@
 
 'use strict';
 
-import CKEDITOR from '../ckeditor.js';
+import CKEDITOR from '../../ckeditor.js';
 import Config from './config.js';
 
 /**

+ 24 - 3
packages/ckeditor5-engine/src/plugincollection.js

@@ -5,11 +5,10 @@
 
 'use strict';
 
-import pathUtils from '../ckeditor5/path.js';
 import Plugin from './plugin.js';
 import CKEditorError from './ckeditorerror.js';
 import log from './log.js';
-import load from '../ckeditor5/load.js';
+import load from '../load.js';
 
 /**
  * Manages a list of CKEditor plugins, including loading, resolving dependencies and initialization.
@@ -98,7 +97,7 @@ export default class PluginCollection {
 		}
 
 		function loadPluginByName( pluginName ) {
-			return load( pathUtils.getModulePath( pluginName ) )
+			return load( PluginCollection.getPluginPath( pluginName ) )
 				.then( ( PluginModule ) => {
 					return loadPluginByClass( PluginModule.default, pluginName );
 				} );
@@ -144,6 +143,28 @@ export default class PluginCollection {
 	}
 
 	/**
+	 * Resolves a simplified plugin name to a real path. The returned
+	 * paths are relative to the main `ckeditor.js` file, but they do not start with `./`.
+	 *
+	 * For instance:
+	 *
+	 * * `foo` will be transformed to `ckeditor5/foo/foo.js`,
+	 * * `core/editor` to `ckeditor5/core/editor.js` and
+	 * * `foo/bar/bom` to `ckeditor5/foo/bar/bom.js`.
+	 *
+	 * @param {String} name
+	 * @returns {String} Path to the module.
+	 */
+	static getPluginPath( name ) {
+		// Resolve shortened feature names to `featureName/featureName`.
+		if ( name.indexOf( '/' ) < 0 ) {
+			name = name + '/' + name;
+		}
+
+		return 'ckeditor5/' + name + '.js';
+	}
+
+	/**
 	 * Adds the plugin to the collection. Exposed mainly for testing purposes.
 	 *
 	 * @protected

+ 0 - 94
packages/ckeditor5-engine/tests/_tools/tools.js

@@ -1,94 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-( () => {
-	bender.tools.core = {
-		/**
-		 * Defines CKEditor plugin which is a mock of an editor creator.
-		 *
-		 * If `proto` is not set or it does not define `create()` and `destroy()` methods,
-		 * then they will be set to Sinon spies. Therefore the shortest usage is:
-		 *
-		 *		bender.tools.defineEditorCreatorMock( 'test1' );
-		 *
-		 * 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 ) {
-			bender.amd.define( 'creator-' + creatorName, [ 'core/creator' ], ( Creator ) => {
-				class TestCreator extends Creator {}
-
-				if ( proto ) {
-					for ( let propName in proto ) {
-						TestCreator.prototype[ propName ] = proto[ propName ];
-					}
-				}
-
-				if ( !TestCreator.prototype.create ) {
-					TestCreator.prototype.create = sinon.spy().named( creatorName + '-create' );
-				}
-
-				if ( !TestCreator.prototype.destroy ) {
-					TestCreator.prototype.destroy = sinon.spy().named( creatorName + '-destroy' );
-				}
-
-				return TestCreator;
-			} );
-		},
-
-		/**
-		 * Returns the number of elements return by the iterator.
-		 *
-		 *		bender.tools.core.getIteratorCount( [ 1, 2, 3, 4, 5 ] ); // 5;
-		 *
-		 * @param {Iterable.<*>} iterator Any iterator.
-		 * @returns {Number} Number of elements returned by that iterator.
-		 */
-		getIteratorCount( iterator ) {
-			let count = 0;
-
-			for ( let _ of iterator ) { // jshint ignore:line
-				count++;
-			}
-
-			return count;
-		}
-	};
-
-	bender.tools.treemodel = {
-		/**
-		 * Returns tree structure as a simplified string. Elements are uppercase and characters are lowercase.
-		 * Start and end of an element is marked the same way, by the element's name (in uppercase).
-		 *
-		 *		let element = new Element( 'div', [], [ 'abc', new Element( 'p', [], 'foo' ), 'xyz' ] );
-		 *		bender.tools.treemodel.getNodesAndText( element ); // abcPfooPxyz
-		 *
-		 * @param {treeModel.Range} range Range to stringify.
-		 * @returns {String} String representing element inner structure.
-		 */
-		getNodesAndText: ( range ) => {
-			let txt = '';
-
-			for ( let step of range ) {
-				let node = step.node;
-
-				if ( node.character ) {
-					txt += node.character.toLowerCase();
-				} else if ( node.name ) {
-					txt += node.name.toUpperCase();
-				}
-			}
-
-			return txt;
-		}
-	};
-} )();

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

@@ -0,0 +1,98 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+import amdUtils from '/tests/_utils/amd.js';
+
+const utils = {
+	/**
+	 * Defines CKEditor plugin which is a mock of an editor creator.
+	 *
+	 * If `proto` is not set or it does not define `create()` and `destroy()` methods,
+	 * then they will be set to Sinon spies. Therefore the shortest usage is:
+	 *
+	 *		testUtils.defineEditorCreatorMock( 'test1' );
+	 *
+	 * 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 ) {
+		amdUtils.define( 'creator-' + creatorName, [ 'core/creator' ], ( Creator ) => {
+			class TestCreator extends Creator {}
+
+			if ( proto ) {
+				for ( let propName in proto ) {
+					TestCreator.prototype[ propName ] = proto[ propName ];
+				}
+			}
+
+			if ( !TestCreator.prototype.create ) {
+				TestCreator.prototype.create = sinon.spy().named( creatorName + '-create' );
+			}
+
+			if ( !TestCreator.prototype.destroy ) {
+				TestCreator.prototype.destroy = sinon.spy().named( creatorName + '-destroy' );
+			}
+
+			return TestCreator;
+		} );
+	},
+
+	/**
+	 * Returns the number of elements return by the iterator.
+	 *
+	 *		testUtils.getIteratorCount( [ 1, 2, 3, 4, 5 ] ); // 5;
+	 *
+	 * @param {Iterable.<*>} iterator Any iterator.
+	 * @returns {Number} Number of elements returned by that iterator.
+	 */
+	getIteratorCount( iterator ) {
+		let count = 0;
+
+		for ( let _ of iterator ) { // jshint ignore:line
+			count++;
+		}
+
+		return count;
+	}
+};
+
+utils.treemodel = {
+	/**
+	 * Returns tree structure as a simplified string. Elements are uppercase and characters are lowercase.
+	 * Start and end of an element is marked the same way, by the element's name (in uppercase).
+	 *
+	 *		let element = new Element( 'div', [], [ 'abc', new Element( 'p', [], 'foo' ), 'xyz' ] );
+	 *		treemodelUtils.getNodesAndText( element ); // abcPfooPxyz
+	 *
+	 * @param {treeModel.Range} range Range to stringify.
+	 * @returns {String} String representing element inner structure.
+	 */
+	getNodesAndText( range ) {
+		console.error( 'This should be moved to ckeditor5-core/tests/treemodel/_utils/' ); /* jshint ignore:line */
+
+		let txt = '';
+
+		for ( let step of range ) {
+			let node = step.node;
+
+			if ( node.character ) {
+				txt += node.character.toLowerCase();
+			} else if ( node.name ) {
+				txt += node.name.toUpperCase();
+			}
+		}
+
+		return txt;
+	}
+};
+
+export default utils;

+ 9 - 19
packages/ckeditor5-engine/tests/ckeditor/ckeditor.js

@@ -3,21 +3,22 @@
  * For licensing, see LICENSE.md.
  */
 
-/* bender-include: ../_tools/tools.js */
-
 'use strict';
 
-const modules = bender.amd.require( 'ckeditor', 'core/editor', 'core/config' );
+import testUtils from '/tests/_utils/utils.js';
+import coreTestUtils from '/tests/core/_utils/utils.js';
+
+import CKEDITOR from '/ckeditor.js';
+import Editor from '/ckeditor5/core/editor.js';
+import Config from '/ckeditor5/core/config.js';
 
 let content = document.getElementById( 'content' );
 let editorConfig = { creator: 'creator-test' };
 
-bender.tools.createSinonSandbox();
-bender.tools.core.defineEditorCreatorMock( 'test' );
+testUtils.createSinonSandbox();
+coreTestUtils.defineEditorCreatorMock( 'test' );
 
 beforeEach( () => {
-	const CKEDITOR = modules.ckeditor;
-
 	// Destroy all editor instances.
 	while ( CKEDITOR.instances.length ) {
 		CKEDITOR.instances.get( 0 ).destroy();
@@ -25,14 +26,6 @@ beforeEach( () => {
 } );
 
 describe( 'create', () => {
-	let CKEDITOR, Editor, Config;
-
-	before( () => {
-		CKEDITOR = modules.ckeditor;
-		Editor = modules[ 'core/editor' ];
-		Config = modules[ 'core/config' ];
-	} );
-
 	it( 'should return a promise', () => {
 		expect( CKEDITOR.create( content, editorConfig ) ).to.be.instanceof( Promise );
 	} );
@@ -91,7 +84,7 @@ describe( 'create', () => {
 	} );
 
 	it( 'should be rejected on element not found', () => {
-		let addSpy = bender.sinon.spy( CKEDITOR.instances, 'add' );
+		let addSpy = testUtils.sinon.spy( CKEDITOR.instances, 'add' );
 
 		return CKEDITOR.create( '.undefined' ).then( () => {
 			throw new Error( 'It should not enter this function' );
@@ -107,9 +100,6 @@ describe( 'create', () => {
 
 describe( 'config', () => {
 	it( 'should be an instance of Config', () => {
-		const CKEDITOR = modules.ckeditor;
-		const Config = modules[ 'core/config' ];
-
 		expect( CKEDITOR.config ).to.be.an.instanceof( Config );
 	} );
 } );

+ 1 - 7
packages/ckeditor5-engine/tests/ckeditorerror.js

@@ -5,15 +5,9 @@
 
 'use strict';
 
-const modules = bender.amd.require( 'core/ckeditorerror' );
+import CKEditorError from '/ckeditor5/core/ckeditorerror.js';
 
 describe( 'CKEditorError', () => {
-	let CKEditorError;
-
-	before( () => {
-		CKEditorError = modules[ 'core/ckeditorerror' ];
-	} );
-
 	it( 'inherits from Error', () => {
 		let error = new CKEditorError( 'foo' );
 

+ 9 - 14
packages/ckeditor5-engine/tests/collection.js

@@ -5,9 +5,12 @@
 
 'use strict';
 
-const modules = bender.amd.require( 'core/collection', 'core/ckeditorerror', 'core/utils' );
+import testUtils from '/tests/_utils/utils.js';
+import Collection from '/ckeditor5/core/collection.js';
+import CKEditorError from '/ckeditor5/core/ckeditorerror.js';
+import utils from '/ckeditor5/core/utils.js';
 
-bender.tools.createSinonSandbox();
+testUtils.createSinonSandbox();
 
 function getItem( id, idProperty ) {
 	idProperty = idProperty || 'id';
@@ -18,14 +21,6 @@ function getItem( id, idProperty ) {
 }
 
 describe( 'Collection', () => {
-	let Collection, CKEditorError, utils;
-
-	before( () => {
-		Collection = modules[ 'core/collection' ];
-		CKEditorError = modules[ 'core/ckeditorerror' ];
-		utils = modules[ 'core/utils' ];
-	} );
-
 	let collection;
 
 	beforeEach( () => {
@@ -150,7 +145,7 @@ describe( 'Collection', () => {
 			() => {
 				let nextUid = 0;
 
-				bender.sinon.stub( utils, 'uid', () => {
+				testUtils.sinon.stub( utils, 'uid', () => {
 					return nextUid++;
 				} );
 
@@ -440,7 +435,7 @@ describe( 'Collection', () => {
 
 	describe( 'map', () => {
 		it( 'uses native map', () => {
-			let spy = bender.sinon.stub( Array.prototype, 'map', () => {
+			let spy = testUtils.sinon.stub( Array.prototype, 'map', () => {
 				return [ 'foo' ];
 			} );
 			let ctx = {};
@@ -458,7 +453,7 @@ describe( 'Collection', () => {
 		it( 'uses native find', () => {
 			let needl = getItem( 'foo' );
 
-			let spy = bender.sinon.stub( Array.prototype, 'find', () => {
+			let spy = testUtils.sinon.stub( Array.prototype, 'find', () => {
 				return needl;
 			} );
 			let ctx = {};
@@ -476,7 +471,7 @@ describe( 'Collection', () => {
 		it( 'uses native filter', () => {
 			let needl = getItem( 'foo' );
 
-			let spy = bender.sinon.stub( Array.prototype, 'filter', () => {
+			let spy = testUtils.sinon.stub( Array.prototype, 'filter', () => {
 				return [ needl ];
 			} );
 			let ctx = {};

+ 2 - 6
packages/ckeditor5-engine/tests/config.js

@@ -5,13 +5,9 @@
 
 'use strict';
 
-const modules = bender.amd.require( 'core/config' );
+import Config from '/ckeditor5/core/config.js';
 
-let Config, config;
-
-before( () => {
-	Config = modules[ 'core/config' ];
-} );
+let config;
 
 beforeEach( () => {
 	config = new Config( {

+ 15 - 19
packages/ckeditor5-engine/tests/editor/creator.js

@@ -5,11 +5,14 @@
 
 'use strict';
 
-/* bender-include: ../_tools/tools.js */
+import amdUtils from '/tests/_utils/amd.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/core/ckeditorerror.js';
 
-const modules = bender.amd.require( 'core/editor', 'core/plugin', 'core/creator', 'core/ckeditorerror' );
 let editor, element;
-let Editor, Plugin, Creator, CKEditorError;
 
 function initEditor( config ) {
 	element = document.createElement( 'div' );
@@ -20,29 +23,22 @@ function initEditor( config ) {
 	return editor.init();
 }
 
-bender.tools.createSinonSandbox();
+testUtils.createSinonSandbox();
 
 before( () => {
-	Editor = modules[ 'core/editor' ];
-	Plugin = modules[ 'core/plugin' ];
-	Creator = modules[ 'core/creator' ];
-	CKEditorError = modules[ 'core/ckeditorerror' ];
+	coreTestUtils.defineEditorCreatorMock( 'test1' );
 
-	const coreTools = bender.tools.core;
+	coreTestUtils.defineEditorCreatorMock( 'test-throw-on-many1' );
+	coreTestUtils.defineEditorCreatorMock( 'test-throw-on-many2' );
 
-	coreTools.defineEditorCreatorMock( 'test1' );
+	coreTestUtils.defineEditorCreatorMock( 'test-config1' );
+	coreTestUtils.defineEditorCreatorMock( 'test-config2' );
 
-	coreTools.defineEditorCreatorMock( 'test-throw-on-many1' );
-	coreTools.defineEditorCreatorMock( 'test-throw-on-many2' );
-
-	coreTools.defineEditorCreatorMock( 'test-config1' );
-	coreTools.defineEditorCreatorMock( 'test-config2' );
-
-	bender.amd.define( 'test3', [ 'core/plugin' ], ( Plugin ) => {
+	amdUtils.define( 'test3', [ 'core/plugin' ], ( Plugin ) => {
 		return class extends Plugin {};
 	} );
 
-	bender.amd.define( 'creator-async-create', [ 'core/creator' ], ( Creator ) => {
+	amdUtils.define( 'creator-async-create', [ 'core/creator' ], ( Creator ) => {
 		return class extends Creator {
 			create() {
 				return new Promise( ( resolve, reject ) => {
@@ -54,7 +50,7 @@ before( () => {
 		};
 	} );
 
-	bender.amd.define( 'creator-async-destroy', [ 'core/creator' ], ( Creator ) => {
+	amdUtils.define( 'creator-async-destroy', [ 'core/creator' ], ( Creator ) => {
 		return class extends Creator {
 			create() {}
 

+ 8 - 11
packages/ckeditor5-engine/tests/editor/editor.js

@@ -3,23 +3,20 @@
  * For licensing, see LICENSE.md.
  */
 
-/* bender-include: ../_tools/tools.js */
-
 'use strict';
 
-const modules = bender.amd.require( 'core/editor', 'core/editorconfig', 'core/plugin' );
-let Editor, EditorConfig, Plugin;
+import amdUtils from '/tests/_utils/amd.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';
 
 const pluginClasses = {};
 let element;
 
 before( () => {
-	Editor = modules[ 'core/editor' ];
-	EditorConfig = modules[ 'core/editorconfig' ];
-	Plugin = modules[ 'core/plugin' ];
-
 	// Define fake plugins to be used in tests.
-	bender.tools.core.defineEditorCreatorMock( 'test', {
+	coreTestUtils.defineEditorCreatorMock( 'test', {
 		init: sinon.spy().named( 'creator-test' )
 	} );
 
@@ -122,7 +119,7 @@ describe( 'init', () => {
 		// Synchronous plugin that depends on an asynchronous one.
 		pluginDefinition( 'sync', [ 'async' ] );
 
-		bender.amd.define( 'async', () => {
+		amdUtils.define( 'async', () => {
 			PluginAsync.prototype.init = sinon.spy( () => {
 				return new Promise( ( resolve ) => {
 					setTimeout( () => {
@@ -187,7 +184,7 @@ describe( 'destroy', () => {
  * @param {String[]} deps Dependencies of the plugin (only other plugins).
  */
 function pluginDefinition( name, deps ) {
-	bender.amd.define( name, deps || [], function() {
+	amdUtils.define( name, deps || [], function() {
 		class NewPlugin extends Plugin {}
 
 		NewPlugin.prototype.init = sinon.spy().named( name );

+ 2 - 5
packages/ckeditor5-engine/tests/editorconfig.js

@@ -5,13 +5,12 @@
 
 'use strict';
 
-const modules = bender.amd.require( 'core/editorconfig', 'ckeditor' );
+import EditorConfig from '/ckeditor5/core/editorconfig.js';
+import CKEDITOR from '/ckeditor.js';
 
 let config;
 
 beforeEach( () => {
-	const EditorConfig = modules[ 'core/editorconfig' ];
-
 	config = new EditorConfig( {
 		test: 1
 	} );
@@ -29,8 +28,6 @@ describe( 'get', () => {
 	} );
 
 	it( 'should fallback to CKEDITOR.config', () => {
-		const CKEDITOR = modules.ckeditor;
-
 		CKEDITOR.config.set( {
 			globalConfig: 2
 		} );

+ 4 - 8
packages/ckeditor5-engine/tests/emittermixin.js

@@ -5,15 +5,11 @@
 
 'use strict';
 
-const modules = bender.amd.require( 'core/emittermixin', 'core/eventinfo', 'core/lib/lodash/object' );
-let EmitterMixin, EventInfo, utilsObject;
-let emitter, listener;
+import EmitterMixin from '/ckeditor5/core/emittermixin.js';
+import EventInfo from '/ckeditor5/core/eventinfo.js';
+import utilsObject from '/ckeditor5/core/lib/lodash/object.js';
 
-before( () => {
-	EmitterMixin = modules[ 'core/emittermixin' ];
-	EventInfo = modules[ 'core/eventinfo' ];
-	utilsObject = modules[ 'core/lib/lodash/object' ];
-} );
+let emitter, listener;
 
 beforeEach( refreshEmitter );
 

+ 1 - 7
packages/ckeditor5-engine/tests/eventinfo.js

@@ -5,15 +5,9 @@
 
 'use strict';
 
-const modules = bender.amd.require( 'core/eventinfo' );
+import EventInfo from '/ckeditor5/core/eventinfo.js';
 
 describe( 'EventInfo', () => {
-	let EventInfo;
-
-	before( () => {
-		EventInfo = modules[ 'core/eventinfo' ];
-	} );
-
 	it( 'should be created properly', () => {
 		let event = new EventInfo( this, 'test' );
 

+ 1 - 7
packages/ckeditor5-engine/tests/lodash.js

@@ -5,15 +5,9 @@
 
 'use strict';
 
-const modules = bender.amd.require( 'core/lib/lodash/object' );
+import objectUtils from '/ckeditor5/core/lib/lodash/object.js';
 
 describe( 'utils', () => {
-	let objectUtils;
-
-	before( () => {
-		objectUtils = modules[ 'core/lib/lodash/object' ];
-	} );
-
 	describe( 'extend()', () => {
 		// Properties of the subsequent objects should override properties of the preceding objects. This is critical for
 		// CKEditor so we keep this test to ensure that Lo-Dash (or whatever) implements it in the way we need it.

+ 2 - 4
packages/ckeditor5-engine/tests/log.js

@@ -7,13 +7,11 @@
 
 'use strict';
 
-const modules = bender.amd.require( 'core/log' );
-let log;
+import log from '/ckeditor5/core/log.js';
+
 let spy;
 
 beforeEach( () => {
-	log = modules[ 'core/log' ];
-
 	if ( spy ) {
 		spy.restore();
 	}

+ 5 - 10
packages/ckeditor5-engine/tests/model.js

@@ -5,21 +5,16 @@
 
 'use strict';
 
-const modules = bender.amd.require( 'core/model', 'core/eventinfo', 'core/ckeditorerror' );
+import testUtils from '/tests/_utils/utils.js';
+import Model from '/ckeditor5/core/model.js';
+import EventInfo from '/ckeditor5/core/eventinfo.js';
+import CKEditorError from '/ckeditor5/core/ckeditorerror.js';
 
 let Car, car;
 
-bender.tools.createSinonSandbox();
+testUtils.createSinonSandbox();
 
 describe( 'Model', () => {
-	let Model, EventInfo, CKEditorError;
-
-	before( () => {
-		Model = modules[ 'core/model' ];
-		EventInfo = modules[ 'core/eventinfo' ];
-		CKEditorError = modules[ 'core/ckeditorerror' ];
-	} );
-
 	beforeEach( 'Create a test model instance', () => {
 		Car = class extends Model {};
 

+ 3 - 5
packages/ckeditor5-engine/tests/plugin.js

@@ -5,19 +5,17 @@
 
 'use strict';
 
-const modules = bender.amd.require( 'core/plugin', 'core/editor' );
+import Plugin from '/ckeditor5/core/plugin.js';
+import Editor from '/ckeditor5/core/editor.js';
+
 let editor;
 
 before( () => {
-	const Editor = modules[ 'core/editor' ];
-
 	editor = new Editor( document.body.appendChild( document.createElement( 'div' ) ) );
 } );
 
 describe( 'constructor', () => {
 	it( 'should set the `editor` property', () => {
-		const Plugin = modules[ 'core/plugin' ];
-
 		let plugin = new Plugin( editor );
 
 		expect( plugin ).to.have.property( 'editor' ).to.equal( editor );

+ 38 - 30
packages/ckeditor5-engine/tests/plugincollection.js

@@ -5,30 +5,22 @@
 
 'use strict';
 
-const modules = bender.amd.require(
-	'core/editor',
-	'core/plugincollection',
-	'core/plugin',
-	'core/creator',
-	'core/ckeditorerror',
-	'core/log'
-);
-let PluginCollection, Plugin, Editor, Creator, CKEditorError, log;
+import amdUtils from '/tests/_utils/amd.js';
+import testUtils from '/tests/_utils/utils.js';
+import Editor from '/ckeditor5/core/editor.js';
+import PluginCollection from '/ckeditor5/core/plugincollection.js';
+import Plugin from '/ckeditor5/core/plugin.js';
+import Creator from '/ckeditor5/core/creator.js';
+import CKEditorError from '/ckeditor5/core/ckeditorerror.js';
+import log from '/ckeditor5/core/log.js';
 
 let editor;
 let PluginA, PluginB, PluginC, PluginD, PluginE, PluginF, PluginG;
 class TestError extends Error {}
 
-bender.tools.createSinonSandbox();
+testUtils.createSinonSandbox();
 
 before( () => {
-	PluginCollection = modules[ 'core/plugincollection' ];
-	Editor = modules[ 'core/editor' ];
-	Plugin = modules[ 'core/plugin' ];
-	Creator = modules[ 'core/creator' ];
-	CKEditorError = modules[ 'core/ckeditorerror' ];
-	log = modules[ 'core/log' ];
-
 	PluginA = createPlugin( 'A' );
 	PluginB = createPlugin( 'B' );
 	PluginC = createPlugin( 'C' );
@@ -47,41 +39,41 @@ before( () => {
 
 // Create fake plugins that will be used on tests.
 
-bender.amd.define( 'A', () => {
+amdUtils.define( 'A', () => {
 	return PluginA;
 } );
 
-bender.amd.define( 'B', () => {
+amdUtils.define( 'B', () => {
 	return PluginB;
 } );
 
-bender.amd.define( 'C', [ 'core/plugin', 'B' ], () => {
+amdUtils.define( 'C', [ 'core/editor', 'B' ], () => {
 	return PluginC;
 } );
 
-bender.amd.define( 'D', [ 'core/plugin', 'A', 'C' ], () => {
+amdUtils.define( 'D', [ 'core/editor', 'A', 'C' ], () => {
 	return PluginD;
 } );
 
-bender.amd.define( 'E', [ 'core/plugin', 'F' ], () => {
+amdUtils.define( 'E', [ 'core/editor', 'F' ], () => {
 	return PluginE;
 } );
 
-bender.amd.define( 'F', [ 'core/plugin', 'E' ], () => {
+amdUtils.define( 'F', [ 'core/editor', 'E' ], () => {
 	return PluginF;
 } );
 
-bender.amd.define( 'G', () => {
+amdUtils.define( 'G', () => {
 	return PluginG;
 } );
 
 // Erroneous cases.
 
-bender.amd.define( 'X', () => {
+amdUtils.define( 'X', () => {
 	throw new TestError( 'Some error inside a plugin' );
 } );
 
-bender.amd.define( 'Y', () => {
+amdUtils.define( 'Y', () => {
 	return class {};
 } );
 
@@ -194,7 +186,7 @@ describe( 'load', () => {
 	} );
 
 	it( 'should reject on invalid plugin names (forward require.js loading error)', () => {
-		let logSpy = bender.sinon.stub( log, 'error' );
+		let logSpy = testUtils.sinon.stub( log, 'error' );
 
 		let plugins = new PluginCollection( editor );
 
@@ -214,7 +206,7 @@ describe( 'load', () => {
 	} );
 
 	it( 'should reject on broken plugins (forward the error thrown in a plugin)', () => {
-		let logSpy = bender.sinon.stub( log, 'error' );
+		let logSpy = testUtils.sinon.stub( log, 'error' );
 
 		let plugins = new PluginCollection( editor );
 
@@ -233,7 +225,7 @@ describe( 'load', () => {
 	} );
 
 	it( 'should reject when loading a module which is not a plugin', () => {
-		let logSpy = bender.sinon.stub( log, 'error' );
+		let logSpy = testUtils.sinon.stub( log, 'error' );
 
 		let plugins = new PluginCollection( editor );
 
@@ -252,8 +244,24 @@ describe( 'load', () => {
 	} );
 } );
 
+describe( 'getPluginPath()', () => {
+	it( 'generates path for modules within some package', () => {
+		const p = PluginCollection.getPluginPath( 'some/ba' );
+
+		expect( p ).to.equal( 'ckeditor5/some/ba.js' );
+	} );
+
+	it( 'generates path from simplified feature name', () => {
+		const p = PluginCollection.getPluginPath( 'foo' );
+
+		expect( p ).to.equal( 'ckeditor5/foo/foo.js' );
+	} );
+} );
+
 function createPlugin( name, baseClass ) {
-	const P = class extends ( baseClass || Plugin ) {
+	baseClass = baseClass || Plugin;
+
+	const P = class extends baseClass {
 		constructor( editor ) {
 			super( editor );
 			this._pluginName = name;

+ 23 - 24
packages/ckeditor5-engine/tests/bender/tools.js

@@ -3,55 +3,54 @@
  * For licensing, see LICENSE.md.
  */
 
-/* bender-include: ../_tools/tools.js */
-
 'use strict';
 
+import amdTestUtils from '/tests/_utils/amd.js';
+import coreTestUtils from '/tests/core/_utils/utils.js';
+import Creator from '/ckeditor5/core/creator.js';
+
 let createFn3 = () => {};
 let destroyFn3 = () => {};
 
-bender.tools.core.defineEditorCreatorMock( 'test1' );
-bender.tools.core.defineEditorCreatorMock( 'test2', {
+coreTestUtils.defineEditorCreatorMock( 'test1' );
+coreTestUtils.defineEditorCreatorMock( 'test2', {
 	foo: 1,
 	bar: 2
 } );
-bender.tools.core.defineEditorCreatorMock( 'test3', {
+coreTestUtils.defineEditorCreatorMock( 'test3', {
 	create: createFn3,
 	destroy: destroyFn3
 } );
 
-const modules = bender.amd.require( 'core/creator', 'creator-test1', 'creator-test2', 'creator-test3' );
-let Creator;
+const modules = amdTestUtils.require( {
+	testCreator1: 'creator-test1/creator-test1',
+	testCreator2: 'creator-test2/creator-test2',
+	testCreator3: 'creator-test3/creator-test3'
+} );
 
 ///////////////////
 
+let TestCreator1, TestCreator2, TestCreator3;
+
 before( () => {
-	Creator = modules[ 'core/creator' ];
+	TestCreator1 = modules.testCreator1;
+	TestCreator2 = modules.testCreator2;
+	TestCreator3 = modules.testCreator3;
 } );
 
-describe( 'bender.tools.core.defineEditorCreatorMock()', () => {
+describe( 'coreTestUtils.defineEditorCreatorMock()', () => {
 	it( 'should register all creators', () => {
-		const TestCreator1 = modules[ 'creator-test1' ];
-		const TestCreator2 = modules[ 'creator-test2' ];
-		const TestCreator3 = modules[ 'creator-test3' ];
-
 		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', () => {
-		const TestCreator = modules[ 'creator-test2' ];
-
-		expect( TestCreator.prototype ).to.have.property( 'foo', 1 );
-		expect( TestCreator.prototype ).to.have.property( 'bar', 2 );
+		expect( TestCreator2.prototype ).to.have.property( 'foo', 1 );
+		expect( TestCreator2.prototype ).to.have.property( 'bar', 2 );
 	} );
 
 	it( 'should create spies for create() and destroy() if not defined', () => {
-		const TestCreator1 = modules[ 'creator-test1' ];
-		const TestCreator2 = modules[ 'creator-test2' ];
-		const TestCreator3 = modules[ 'creator-test3' ];
-
 		expect( TestCreator1.prototype.create ).to.have.property( 'called', false, 'test1.create' );
 		expect( TestCreator1.prototype.destroy ).to.have.property( 'called', false, 'test1.destroy' );
 		expect( TestCreator2.prototype.create ).to.have.property( 'called', false, 'test2.create' );
@@ -63,9 +62,9 @@ describe( 'bender.tools.core.defineEditorCreatorMock()', () => {
 	} );
 } );
 
-describe( 'bender.tools.core.getIteratorCount()', () => {
+describe( 'coreTestUtils.getIteratorCount()', () => {
 	it( 'should returns number of editable items ', () => {
-		const count = bender.tools.core.getIteratorCount( [ 1, 2, 3, 4, 5 ] );
+		const count = coreTestUtils.getIteratorCount( [ 1, 2, 3, 4, 5 ] );
 		expect( count ).to.equal( 5 );
 	} );
-} );
+} );

+ 1 - 7
packages/ckeditor5-engine/tests/utils.js

@@ -5,15 +5,9 @@
 
 'use strict';
 
-const modules = bender.amd.require( 'core/utils' );
+import utils from '/ckeditor5/core/utils.js';
 
 describe( 'utils', () => {
-	let utils;
-
-	before( () => {
-		utils = modules[ 'core/utils' ];
-	} );
-
 	describe( 'spy', () => {
 		it( 'should not have `called` after creation', () => {
 			let spy = utils.spy();