Kaynağa Gözat

Re-reviewed tests to use bender.amd.require().

fredck 11 yıl önce
ebeveyn
işleme
338f468162
3 değiştirilmiş dosya ile 45 ekleme ve 43 silme
  1. 3 0
      gruntfile.js
  2. 14 16
      tests/ckeditor/basepath.js
  3. 28 27
      tests/ckeditor/ckeditor.js

+ 3 - 0
gruntfile.js

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

+ 14 - 16
tests/ckeditor/basepath.js

@@ -3,7 +3,7 @@
  * For licensing, see LICENSE.md.
  */
 
-/* globals beforeEach, describe, it, expect, CKEDITOR, window, document */
+/* globals beforeEach, describe, it, expect, window, document */
 
 'use strict';
 
@@ -16,33 +16,31 @@ beforeEach( function() {
 } );
 
 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();
-		} );
+	var modules = bender.amd.require( 'ckeditor' );
+
+	it( 'should work with script tags', function() {
+		var CKEDITOR = modules.ckeditor;
+
+		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() {
+		var CKEDITOR = modules.ckeditor;
+
+		window.CKEDITOR_BASEPATH = 'http://foo.com/ckeditor/';
+		expect( CKEDITOR._getBasePath() ).to.equal( 'http://foo.com/ckeditor/' );
 	} );
 } );
 
 describe( 'This browser', function() {
-	it( 'should not keep script URLs absolute or relative', function( done ) {
+	it( 'should not keep script URLs absolute or relative', function() {
 		// Browsers should convert absolute and relative URLs to full URLs.
 		// If this test fails in any browser, _getBasePath() must be reviewed to deal with such case (v4 does it).
 
 		test( '/absolute/url/ckeditor.js' );
 		test( '../relative/url/ckeditor.js' );
 
-		done();
-
 		function test( url ) {
 			removeScripts();
 

+ 28 - 27
tests/ckeditor/ckeditor.js

@@ -3,41 +3,42 @@
  * 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();
-		} );
+	var modules = bender.amd.require( 'ckeditor', 'ckeditor-core' );
+
+	it( 'should return a proper path', function() {
+		var CKEDITOR = modules.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/' );
+		}
 	} );
 
-	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() {
+		var CKEDITOR = modules.ckeditor;
+		var core = modules[ 'ckeditor-core' ];
 
-			// This test is good for both the development and production codes.
-			var basePath = CKEDITOR.basePath;
-			var path = CKEDITOR.getPluginPath( 'test' );
+		// 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;
 
-			// Revert the override before assertions or it will not do it in case of errors.
-			CKEDITOR.getPluginPath = originalGetPluginPath;
+		// This test is good for both the development and production codes.
+		var basePath = CKEDITOR.basePath;
+		var path = CKEDITOR.getPluginPath( 'test' );
 
-			expect( path ).to.equal( basePath + 'plugins/test/' );
-			done();
-		} );
+		// 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/' );
 	} );
 } );