瀏覽代碼

Tests: Sinon isn't global before tests are executed.

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

+ 22 - 19
packages/ckeditor5-engine/tests/editor/editor.js

@@ -11,6 +11,7 @@ var modules = bender.amd.require( 'editor', 'editorconfig', 'plugin', 'promise'
 
 var editor;
 var element;
+var asyncSpy;
 
 beforeEach( function() {
 	var Editor = modules.editor;
@@ -21,36 +22,38 @@ beforeEach( function() {
 	editor = new Editor( element );
 } );
 
-// Define fake plugins to be used in tests.
+before( function() {
+	// Define fake plugins to be used in tests.
 
-CKEDITOR.define( 'plugin!A', [ 'plugin' ], pluginDefinition( 'A' ) );
+	CKEDITOR.define( 'plugin!A', [ 'plugin' ], pluginDefinition( 'A' ) );
 
-CKEDITOR.define( 'plugin!B', [ 'plugin' ], pluginDefinition( 'B' ) );
+	CKEDITOR.define( 'plugin!B', [ 'plugin' ], pluginDefinition( 'B' ) );
 
-CKEDITOR.define( 'plugin!C', [ 'plugin', 'plugin!B' ], pluginDefinition( 'C' ) );
+	CKEDITOR.define( 'plugin!C', [ 'plugin', 'plugin!B' ], pluginDefinition( 'C' ) );
 
-CKEDITOR.define( 'plugin!D', [ 'plugin', 'plugin!C' ], pluginDefinition( 'D' ) );
+	CKEDITOR.define( 'plugin!D', [ 'plugin', 'plugin!C' ], pluginDefinition( 'D' ) );
 
-CKEDITOR.define( 'plugin!E', [ 'plugin' ], pluginDefinition( 'E' ) );
+	CKEDITOR.define( 'plugin!E', [ 'plugin' ], pluginDefinition( 'E' ) );
 
-// Synchronous plugin that depends on an asynchronous one.
-CKEDITOR.define( 'plugin!F', [ 'plugin', 'plugin!async' ], pluginDefinition( 'F' ) );
+	// Synchronous plugin that depends on an asynchronous one.
+	CKEDITOR.define( 'plugin!F', [ 'plugin', 'plugin!async' ], pluginDefinition( 'F' ) );
 
-var asyncSpy = sinon.spy().named( 'async-call-spy' );
+	asyncSpy = sinon.spy().named( 'async-call-spy' );
 
-CKEDITOR.define( 'plugin!async', [ 'plugin', 'promise' ], function( Plugin, Promise ) {
-	class PluginAsync extends Plugin {}
+	CKEDITOR.define( 'plugin!async', [ 'plugin', 'promise' ], function( Plugin, Promise ) {
+		class PluginAsync extends Plugin {}
 
-	PluginAsync.prototype.init = sinon.spy( function() {
-		return new Promise( function( resolve ) {
-			setTimeout( function() {
-				asyncSpy();
-				resolve();
-			}, 0 );
+		PluginAsync.prototype.init = sinon.spy( function() {
+			return new Promise( function( resolve ) {
+				setTimeout( function() {
+					asyncSpy();
+					resolve();
+				}, 0 );
+			} );
 		} );
-	} );
 
-	return PluginAsync;
+		return PluginAsync;
+	} );
 } );
 
 function pluginDefinition( name ) {

+ 8 - 2
packages/ckeditor5-engine/tests/plugincollection/plugincollection.js

@@ -11,9 +11,15 @@ var modules = bender.amd.require( 'plugincollection', 'plugin', 'editor', 'log'
 var editor;
 var PluginA, PluginB;
 class TestError extends Error {}
+var sandbox;
 
-var sandbox = sinon.sandbox.create();
-afterEach( sandbox.restore.bind( sandbox ) );
+// TODO move to bender.tools.createSinonSandbox().
+before( function() {
+	sandbox = sinon.sandbox.create();
+} );
+afterEach( function() {
+	sandbox.restore();
+} );
 
 before( function() {
 	var Editor = modules.editor;