Sfoglia il codice sorgente

Tests: Added missing tests for a case when we call load() with some undefined or empty value.

Piotrek Koszuliński 10 anni fa
parent
commit
139bbc548b

+ 1 - 0
packages/ckeditor5-engine/src/plugincollection.js

@@ -47,6 +47,7 @@ CKEDITOR.define( [
 			// The list of plugins which are being loaded (to avoid circular references issues).
 			var loading = {};
 
+			// It may happen that an empty list was passed – don't fail.
 			plugins = plugins ? plugins.split( ',' ) : [];
 
 			// Creates a promise for the loading of each plugin and returns a main promise that resolves when all are

+ 22 - 0
packages/ckeditor5-engine/tests/plugincollection/plugincollection.js

@@ -93,6 +93,28 @@ CKEDITOR.define( 'plugin!J', function() {
 /////////////
 
 describe( 'load', function() {
+	it( 'should not fail when trying to load 0 plugins (empty string)', function() {
+		var PluginCollection = modules.plugincollection;
+
+		var plugins = new PluginCollection( editor );
+
+		return plugins.load( '' )
+			.then( function() {
+				expect( plugins.length ).to.equal( 0 );
+			} );
+	} );
+
+	it( 'should not fail when trying to load 0 plugins (undefined)', function() {
+		var PluginCollection = modules.plugincollection;
+
+		var plugins = new PluginCollection( editor );
+
+		return plugins.load()
+			.then( function() {
+				expect( plugins.length ).to.equal( 0 );
+			} );
+	} );
+
 	it( 'should add collection items for loaded plugins', function() {
 		var PluginCollection = modules.plugincollection;