浏览代码

Merge pull request #208 from ckeditor/t/207

Using format-independent module utils in tests.
Piotrek Koszuliński 9 年之前
父节点
当前提交
f3fabb8042

+ 2 - 2
packages/ckeditor5-engine/tests/_utils/utils.js

@@ -7,7 +7,7 @@
 
 /* global console:false */
 
-import amdUtils from '/tests/_utils/amd.js';
+import moduleUtils from '/tests/_utils/module.js';
 import EmitterMixin from '/ckeditor5/core/emittermixin.js';
 
 const utils = {
@@ -23,7 +23,7 @@ const utils = {
 	 * be copied to the prototype of the creator.
 	 */
 	defineEditorCreatorMock( creatorName, proto ) {
-		amdUtils.define( 'creator-' + creatorName, [ 'core/creator' ], ( Creator ) => {
+		moduleUtils.define( 'creator-' + creatorName, [ 'core/creator' ], ( Creator ) => {
 			class TestCreator extends Creator {}
 
 			if ( proto ) {

+ 5 - 5
packages/ckeditor5-engine/tests/editor/creator.js

@@ -7,7 +7,7 @@
 
 /* bender-tags: editor, creator */
 
-import amdUtils from '/tests/_utils/amd.js';
+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';
@@ -43,11 +43,11 @@ before( () => {
 		create: sinon.spy()
 	} );
 
-	amdUtils.define( 'test3', [ 'core/plugin' ], ( Plugin ) => {
+	moduleUtils.define( 'test3', [ 'core/plugin' ], ( Plugin ) => {
 		return class extends Plugin {};
 	} );
 
-	amdUtils.define( 'creator-async-create', [ 'core/creator' ], ( Creator ) => {
+	moduleUtils.define( 'creator-async-create', [ 'core/creator' ], ( Creator ) => {
 		return class extends Creator {
 			create() {
 				return new Promise( ( resolve, reject ) => {
@@ -59,7 +59,7 @@ before( () => {
 		};
 	} );
 
-	amdUtils.define( 'creator-async-destroy', [ 'core/creator' ], ( Creator ) => {
+	moduleUtils.define( 'creator-async-destroy', [ 'core/creator' ], ( Creator ) => {
 		return class extends Creator {
 			create() {}
 
@@ -71,7 +71,7 @@ before( () => {
 		};
 	} );
 
-	amdUtils.define( 'creator-destroy-order', [ 'core/creator' ], ( Creator ) => {
+	moduleUtils.define( 'creator-destroy-order', [ 'core/creator' ], ( Creator ) => {
 		return class extends Creator {
 			create() {}
 

+ 3 - 3
packages/ckeditor5-engine/tests/editor/editor.js

@@ -7,7 +7,7 @@
 
 /* bender-tags: editor */
 
-import amdUtils from '/tests/_utils/amd.js';
+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';
@@ -121,7 +121,7 @@ describe( 'init', () => {
 		// Synchronous plugin that depends on an asynchronous one.
 		pluginDefinition( 'sync', [ 'async' ] );
 
-		amdUtils.define( 'async', () => {
+		moduleUtils.define( 'async', () => {
 			PluginAsync.prototype.init = sinon.spy( () => {
 				return new Promise( ( resolve ) => {
 					setTimeout( () => {
@@ -211,7 +211,7 @@ describe( 'setData', () => {
  * @param {String[]} deps Dependencies of the plugin (only other plugins).
  */
 function pluginDefinition( name, deps ) {
-	amdUtils.define( name, deps || [], function() {
+	moduleUtils.define( name, deps || [], function() {
 		class NewPlugin extends Plugin {}
 
 		NewPlugin.prototype.init = sinon.spy().named( name );

+ 11 - 11
packages/ckeditor5-engine/tests/plugincollection.js

@@ -5,7 +5,7 @@
 
 'use strict';
 
-import amdUtils from '/tests/_utils/amd.js';
+import moduleUtils from '/tests/_utils/module.js';
 import testUtils from '/tests/_utils/utils.js';
 import Editor from '/ckeditor5/core/editor.js';
 import PluginCollection from '/ckeditor5/core/plugincollection.js';
@@ -39,41 +39,41 @@ before( () => {
 
 // Create fake plugins that will be used on tests.
 
-amdUtils.define( 'A', () => {
+moduleUtils.define( 'A', () => {
 	return PluginA;
 } );
 
-amdUtils.define( 'B', () => {
+moduleUtils.define( 'B', () => {
 	return PluginB;
 } );
 
-amdUtils.define( 'C', [ 'core/editor', 'B' ], () => {
+moduleUtils.define( 'C', [ 'core/editor', 'B' ], () => {
 	return PluginC;
 } );
 
-amdUtils.define( 'D', [ 'core/editor', 'A', 'C' ], () => {
+moduleUtils.define( 'D', [ 'core/editor', 'A', 'C' ], () => {
 	return PluginD;
 } );
 
-amdUtils.define( 'E', [ 'core/editor', 'F' ], () => {
+moduleUtils.define( 'E', [ 'core/editor', 'F' ], () => {
 	return PluginE;
 } );
 
-amdUtils.define( 'F', [ 'core/editor', 'E' ], () => {
+moduleUtils.define( 'F', [ 'core/editor', 'E' ], () => {
 	return PluginF;
 } );
 
-amdUtils.define( 'G', () => {
+moduleUtils.define( 'G', () => {
 	return PluginG;
 } );
 
 // Erroneous cases.
 
-amdUtils.define( 'X', () => {
+moduleUtils.define( 'X', () => {
 	throw new TestError( 'Some error inside a plugin' );
 } );
 
-amdUtils.define( 'Y', () => {
+moduleUtils.define( 'Y', () => {
 	return class {};
 } );
 
@@ -296,4 +296,4 @@ function getPluginsFromSpy( addSpy ) {
 
 function getPluginNames( plugins ) {
 	return plugins.map( ( plugin ) => plugin._pluginName );
-}
+}

+ 2 - 2
packages/ckeditor5-engine/tests/utils-tests/utils.js

@@ -6,7 +6,7 @@
 'use strict';
 
 import testUtils from '/tests/_utils/utils.js';
-import amdTestUtils from '/tests/_utils/amd.js';
+import moduleTestUtils from '/tests/_utils/module.js';
 import coreTestUtils from '/tests/core/_utils/utils.js';
 import Model from '/ckeditor5/core/ui/model.js';
 import Creator from '/ckeditor5/core/creator.js';
@@ -27,7 +27,7 @@ coreTestUtils.defineEditorCreatorMock( 'test3', {
 	destroy: destroyFn3
 } );
 
-const modules = amdTestUtils.require( {
+const modules = moduleTestUtils.require( {
 	testCreator1: 'creator-test1/creator-test1',
 	testCreator2: 'creator-test2/creator-test2',
 	testCreator3: 'creator-test3/creator-test3'