Browse Source

Reviewed tests to use bender.amd.require().

fredck 11 years ago
parent
commit
eeb9b44785
2 changed files with 104 additions and 121 deletions
  1. 2 1
      packages/ckeditor5-engine/gruntfile.js
  2. 102 120
      packages/ckeditor5-engine/tests/utils/utils.js

+ 2 - 1
packages/ckeditor5-engine/gruntfile.js

@@ -18,7 +18,8 @@ module.exports = function( grunt ) {
 		jshint: {
 			options: {
 				globals: {
-					'CKEDITOR': false
+					'CKEDITOR': false,
+					'bender': false
 				},
 				ignores: ignoreFiles
 			}

+ 102 - 120
packages/ckeditor5-engine/tests/utils/utils.js

@@ -7,148 +7,130 @@
 
 'use strict';
 
-describe( 'extend()', function() {
-	it( 'should extend and override', function( done ) {
-		CKEDITOR.require( [ 'utils' ], function( utils ) {
-			var target = {
-				a: 1,
-				b: 2
-			};
+bender.amd.require( 'utils' );
 
-			var extensions = {
-				a: 'A',
-				c: 3,
+describe( 'extend()', function( utils ) {
+	it( 'should extend and override', function() {
+		var target = {
+			a: 1,
+			b: 2
+		};
 
-				// Extend by reference (no deep-copy).
-				obj: {
-					a: 1
-				},
+		var extensions = {
+			a: 'A',
+			c: 3,
 
-				// Extend by reference (no deep-copy).
-				arr: [ 1, 2 ],
+			// Extend by reference (no deep-copy).
+			obj: {
+				a: 1
+			},
 
-				// Extend by reference.
-				fn: function() {}
-			};
+			// Extend by reference (no deep-copy).
+			arr: [ 1, 2 ],
 
-			var ret = utils.extend( target, extensions );
+			// Extend by reference.
+			fn: function() {}
+		};
 
-			expect( target.a ).to.equal( 'A' );
-			expect( target.b ).to.equal( 2 );
-			expect( target ).to.have.property( 'c' ).to.equal( 3 );
+		var ret = utils.extend( target, extensions );
 
-			expect( target ).to.have.property( 'obj' ).to.equal( extensions.obj );
-			expect( target ).to.have.property( 'arr' ).to.equal( extensions.arr );
-			expect( target ).to.have.property( 'fn' ).to.equal( extensions.fn );
+		expect( target.a ).to.equal( 'A' );
+		expect( target.b ).to.equal( 2 );
+		expect( target ).to.have.property( 'c' ).to.equal( 3 );
 
-			// "target" should be the return value.
-			expect( ret ).to.equal( target );
+		expect( target ).to.have.property( 'obj' ).to.equal( extensions.obj );
+		expect( target ).to.have.property( 'arr' ).to.equal( extensions.arr );
+		expect( target ).to.have.property( 'fn' ).to.equal( extensions.fn );
 
-			done();
-		} );
+		// "target" should be the return value.
+		expect( ret ).to.equal( target );
 	} );
 
-	it( 'should not be touched by non-objects', function( done ) {
-		CKEDITOR.require( [ 'utils' ], function( utils ) {
-			var target = {
-				a: 1
-			};
-
-			expect( utils.extend( target, function() {} ) ).to.equal( target );
-			expect( utils.extend( target, 1 ) ).to.equal( target );
-			expect( utils.extend( target, 'a' ) ).to.equal( target );
-			expect( utils.extend( target, true ) ).to.equal( target );
-			expect( utils.extend( target, undefined ) ).to.equal( target );
-			expect( utils.extend( target, [] ) ).to.equal( target );
-			expect( utils.extend( target, Date.now() ) ).to.equal( target );
-			expect( utils.extend( target ) ).to.equal( target );
-
-			// None of the above calls should have touched "target".
-			expect( target ).to.have.property( 'a' ).to.equal( 1 );
-			expect( Object.getOwnPropertyNames( target ).length ).to.equal( 1 );
-
-			done();
-		} );
+	it( 'should not be touched by non-objects', function() {
+		var target = {
+			a: 1
+		};
+
+		expect( utils.extend( target, function() {} ) ).to.equal( target );
+		expect( utils.extend( target, 1 ) ).to.equal( target );
+		expect( utils.extend( target, 'a' ) ).to.equal( target );
+		expect( utils.extend( target, true ) ).to.equal( target );
+		expect( utils.extend( target, undefined ) ).to.equal( target );
+		expect( utils.extend( target, [] ) ).to.equal( target );
+		expect( utils.extend( target, Date.now() ) ).to.equal( target );
+		expect( utils.extend( target ) ).to.equal( target );
+
+		// None of the above calls should have touched "target".
+		expect( target ).to.have.property( 'a' ).to.equal( 1 );
+		expect( Object.getOwnPropertyNames( target ).length ).to.equal( 1 );
 	} );
 
-	it( 'should extend by several params in order', function( done ) {
-		CKEDITOR.require( [ 'utils' ], function( utils ) {
-			var target = {
-				a: 0,
-				b: 0
-			};
-
-			var ext1 = {
-				b: 1,
-				c: 1
-			};
+	it( 'should extend by several params in order', function() {
+		var target = {
+			a: 0,
+			b: 0
+		};
 
-			var ext2 = {
-				c: 2,
-				d: 2
-			};
+		var ext1 = {
+			b: 1,
+			c: 1
+		};
 
-			utils.extend( target, ext1, ext2 );
+		var ext2 = {
+			c: 2,
+			d: 2
+		};
 
-			expect( target ).to.have.property( 'a' ).to.equal( 0 );
-			expect( target ).to.have.property( 'b' ).to.equal( 1 );
-			expect( target ).to.have.property( 'c' ).to.equal( 2 );
-			expect( target ).to.have.property( 'd' ).to.equal( 2 );
+		utils.extend( target, ext1, ext2 );
 
-			done();
-		} );
+		expect( target ).to.have.property( 'a' ).to.equal( 0 );
+		expect( target ).to.have.property( 'b' ).to.equal( 1 );
+		expect( target ).to.have.property( 'c' ).to.equal( 2 );
+		expect( target ).to.have.property( 'd' ).to.equal( 2 );
 	} );
 } );
 
-describe( 'isFunction()', function() {
-	it( 'should be true for functions only', function( done ) {
-		CKEDITOR.require( [ 'utils' ], function( utils ) {
-			var f1 = function() {
-			};
-
-			/* jshint -W054 */	// The Function constructor is a form of eval
-			var f2 = new Function( '' );
-			/* jshint +W054 */
-
-			expect( utils.isFunction( f1 ) ).to.be.true();
-			expect( utils.isFunction( f2 ) ).to.be.true();
-
-			expect( utils.isFunction( 1 ) ).to.be.false();
-			expect( utils.isFunction( 'a' ) ).to.be.false();
-			expect( utils.isFunction( true ) ).to.be.false();
-			expect( utils.isFunction( undefined ) ).to.be.false();
-			expect( utils.isFunction( [] ) ).to.be.false();
-			expect( utils.isFunction( {} ) ).to.be.false();
-			expect( utils.isFunction( Date.now() ) ).to.be.false();
-
-			done();
-		} );
+describe( 'isFunction()', function( utils ) {
+	it( 'should be true for functions only', function() {
+		var f1 = function() {
+		};
+
+		/* jshint -W054 */	// The Function constructor is a form of eval
+		var f2 = new Function( '' );
+		/* jshint +W054 */
+
+		expect( utils.isFunction( f1 ) ).to.be.true();
+		expect( utils.isFunction( f2 ) ).to.be.true();
+
+		expect( utils.isFunction( 1 ) ).to.be.false();
+		expect( utils.isFunction( 'a' ) ).to.be.false();
+		expect( utils.isFunction( true ) ).to.be.false();
+		expect( utils.isFunction( undefined ) ).to.be.false();
+		expect( utils.isFunction( [] ) ).to.be.false();
+		expect( utils.isFunction( {} ) ).to.be.false();
+		expect( utils.isFunction( Date.now() ) ).to.be.false();
 	} );
 } );
 
-describe( 'isObject()', function() {
-	it( 'should be true for pure objects only', function( done ) {
-		CKEDITOR.require( [ 'utils' ], function( utils ) {
-			var f1 = function() {
-			};
-
-			/* jshint -W054 */	// The Function constructor is a form of eval
-			var f2 = new Function( '' );
-			/* jshint +W054 */
-
-			expect( utils.isObject( {} ) ).to.be.true();
-			expect( utils.isObject( [] ) ).to.be.true();
-
-			expect( utils.isObject( 1 ) ).to.be.false();
-			expect( utils.isObject( 'a' ) ).to.be.false();
-			expect( utils.isObject( true ) ).to.be.false();
-			expect( utils.isObject( undefined ) ).to.be.false();
-			expect( utils.isObject( Date.now() ) ).to.be.false();
-			expect( utils.isObject( f1 ) ).to.be.false();
-			expect( utils.isObject( f2 ) ).to.be.false();
-			expect( utils.isObject( null ) ).to.be.false();
-
-			done();
-		} );
+describe( 'isObject()', function( utils ) {
+	it( 'should be true for pure objects only', function() {
+		var f1 = function() {
+		};
+
+		/* jshint -W054 */	// The Function constructor is a form of eval
+		var f2 = new Function( '' );
+		/* jshint +W054 */
+
+		expect( utils.isObject( {} ) ).to.be.true();
+		expect( utils.isObject( [] ) ).to.be.true();
+
+		expect( utils.isObject( 1 ) ).to.be.false();
+		expect( utils.isObject( 'a' ) ).to.be.false();
+		expect( utils.isObject( true ) ).to.be.false();
+		expect( utils.isObject( undefined ) ).to.be.false();
+		expect( utils.isObject( Date.now() ) ).to.be.false();
+		expect( utils.isObject( f1 ) ).to.be.false();
+		expect( utils.isObject( f2 ) ).to.be.false();
+		expect( utils.isObject( null ) ).to.be.false();
 	} );
 } );