Ver código fonte

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

fredck 11 anos atrás
pai
commit
41ec3ce42f
3 arquivos alterados com 37 adições e 42 exclusões
  1. 3 0
      gruntfile.js
  2. 10 14
      tests/ckeditor/basepath.js
  3. 24 28
      tests/ckeditor/ckeditor.js

+ 3 - 0
gruntfile.js

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

+ 10 - 14
tests/ckeditor/basepath.js

@@ -3,10 +3,12 @@
  * For licensing, see LICENSE.md.
  */
 
-/* globals beforeEach, describe, it, expect, CKEDITOR, window, document */
+/* globals beforeEach, describe, it, expect, window, document */
 
 'use strict';
 
+bender.amd.require( 'ckeditor' );
+
 beforeEach( function() {
 	// Ensure that no CKEDITOR_BASEPATH global is available.
 	delete window.CKEDITOR_BASEPATH;
@@ -15,21 +17,15 @@ beforeEach( function() {
 	removeScripts();
 } );
 
-describe( 'basePath', function() {
-	it( 'should work with script tags', function( done ) {
-		CKEDITOR.require( [ 'ckeditor' ], function( CKEDITOR ) {
-			addScript( 'http://bar.com/ckeditor/ckeditor.js' );
-			expect( CKEDITOR._getBasePath() ).to.equal( 'http://bar.com/ckeditor/' );
-			done();
-		} );
+describe( 'basePath', function( CKEDITOR ) {
+	it( 'should work with script tags', function() {
+		addScript( 'http://bar.com/ckeditor/ckeditor.js' );
+		expect( CKEDITOR._getBasePath() ).to.equal( 'http://bar.com/ckeditor/' );
 	} );
 
-	it( 'should work with the CKEDITOR_BASEPATH global', function( done ) {
-		CKEDITOR.require( [ 'ckeditor' ], function( CKEDITOR ) {
-			window.CKEDITOR_BASEPATH = 'http://foo.com/ckeditor/';
-			expect( CKEDITOR._getBasePath() ).to.equal( 'http://foo.com/ckeditor/' );
-			done();
-		} );
+	it( 'should work with the CKEDITOR_BASEPATH global', function() {
+		window.CKEDITOR_BASEPATH = 'http://foo.com/ckeditor/';
+		expect( CKEDITOR._getBasePath() ).to.equal( 'http://foo.com/ckeditor/' );
 	} );
 } );
 

+ 24 - 28
tests/ckeditor/ckeditor.js

@@ -3,41 +3,37 @@
  * For licensing, see LICENSE.md.
  */
 
-/* globals describe, it, expect, CKEDITOR */
+/* globals describe, it, expect */
 
 'use strict';
 
-describe( 'getPluginPath()', function() {
-	it( 'should return a proper path', function( done ) {
-		CKEDITOR.require( [ 'ckeditor' ], function( CKEDITOR ) {
-			var basePath = CKEDITOR.basePath;
-			var path = CKEDITOR.getPluginPath( 'test' );
-
-			if ( CKEDITOR.isDev ) {
-				expect( path ).to.equal( basePath + 'node_modules/ckeditor-plugin-test/src/' );
-			} else {
-				expect( path ).to.equal( basePath + 'plugins/test/' );
-			}
-			done();
-		} );
+bender.amd.require( 'ckeditor', 'ckeditor-core' );
+
+describe( 'getPluginPath()', function( CKEDITOR, core ) {
+	it( 'should return a proper path', function() {
+		var basePath = CKEDITOR.basePath;
+		var path = CKEDITOR.getPluginPath( 'test' );
+
+		if ( CKEDITOR.isDev ) {
+			expect( path ).to.equal( basePath + 'node_modules/ckeditor-plugin-test/src/' );
+		} else {
+			expect( path ).to.equal( basePath + 'plugins/test/' );
+		}
 	} );
 
-	it( '(the production version) should work even when in dev', function( done ) {
-		CKEDITOR.require( [ 'ckeditor', 'ckeditor-core' ], function( CKEDITOR, core ) {
-			// To be able to run this test on both dev and production code, we need to override getPluginPath with the
-			// core version of it and restore it after testing.
-			var originalGetPluginPath = CKEDITOR.getPluginPath;
-			CKEDITOR.getPluginPath = core.getPluginPath;
+	it( '(the production version) should work even when in dev', function() {
+		// To be able to run this test on both dev and production code, we need to override getPluginPath with the
+		// core version of it and restore it after testing.
+		var originalGetPluginPath = CKEDITOR.getPluginPath;
+		CKEDITOR.getPluginPath = core.getPluginPath;
 
-			// This test is good for both the development and production codes.
-			var basePath = CKEDITOR.basePath;
-			var path = CKEDITOR.getPluginPath( 'test' );
+		// This test is good for both the development and production codes.
+		var basePath = CKEDITOR.basePath;
+		var path = CKEDITOR.getPluginPath( 'test' );
 
-			// Revert the override before assertions or it will not do it in case of errors.
-			CKEDITOR.getPluginPath = originalGetPluginPath;
+		// Revert the override before assertions or it will not do it in case of errors.
+		CKEDITOR.getPluginPath = originalGetPluginPath;
 
-			expect( path ).to.equal( basePath + 'plugins/test/' );
-			done();
-		} );
+		expect( path ).to.equal( basePath + 'plugins/test/' );
 	} );
 } );