Przeglądaj źródła

Improved tests.

Piotrek Koszuliński 9 lat temu
rodzic
commit
27f3426e33
1 zmienionych plików z 19 dodań i 5 usunięć
  1. 19 5
      packages/ckeditor5-core/tests/plugincollection.js

+ 19 - 5
packages/ckeditor5-core/tests/plugincollection.js

@@ -244,7 +244,7 @@ describe( 'PluginCollection', () => {
 
 
 			let plugins = new PluginCollection( editor, availablePlugins );
 			let plugins = new PluginCollection( editor, availablePlugins );
 
 
-			return plugins.load( [ 'Non-Existing-Plugin' ] )
+			return plugins.load( [ 'NonExistentPlugin' ] )
 				// Throw here, so if by any chance plugins.load() was resolved correctly catch() will be stil executed.
 				// Throw here, so if by any chance plugins.load() was resolved correctly catch() will be stil executed.
 				.then( () => {
 				.then( () => {
 					throw new Error( 'Test error: this promise should not be resolved successfully' );
 					throw new Error( 'Test error: this promise should not be resolved successfully' );
@@ -258,7 +258,7 @@ describe( 'PluginCollection', () => {
 				} );
 				} );
 		} );
 		} );
 
 
-		it( 'should load allowed plugins (plugins and removePlugins are constructors)', () => {
+		it( 'should load chosen plugins (plugins and removePlugins are constructors)', () => {
 			let plugins = new PluginCollection( editor, availablePlugins );
 			let plugins = new PluginCollection( editor, availablePlugins );
 
 
 			return plugins.load( [ PluginA, PluginB, PluginC ], [ PluginA ] )
 			return plugins.load( [ PluginA, PluginB, PluginC ], [ PluginA ] )
@@ -270,7 +270,7 @@ describe( 'PluginCollection', () => {
 				} );
 				} );
 		} );
 		} );
 
 
-		it( 'should load allowed plugins (plugins are constructors, removePlugins are names)', () => {
+		it( 'should load chosen plugins (plugins are constructors, removePlugins are names)', () => {
 			let plugins = new PluginCollection( editor, availablePlugins );
 			let plugins = new PluginCollection( editor, availablePlugins );
 
 
 			return plugins.load( [ PluginA, PluginB, PluginC ], [ 'A' ] )
 			return plugins.load( [ PluginA, PluginB, PluginC ], [ 'A' ] )
@@ -282,7 +282,7 @@ describe( 'PluginCollection', () => {
 				} );
 				} );
 		} );
 		} );
 
 
-		it( 'should load allowed plugins (plugins and removePlugins are names)', () => {
+		it( 'should load chosen plugins (plugins and removePlugins are names)', () => {
 			let plugins = new PluginCollection( editor, availablePlugins );
 			let plugins = new PluginCollection( editor, availablePlugins );
 
 
 			return plugins.load( [ 'A', 'B', 'C' ], [ 'A' ] )
 			return plugins.load( [ 'A', 'B', 'C' ], [ 'A' ] )
@@ -294,7 +294,7 @@ describe( 'PluginCollection', () => {
 				} );
 				} );
 		} );
 		} );
 
 
-		it( 'should load allowed plugins (plugins are names, removePlugins are constructors)', () => {
+		it( 'should load chosen plugins (plugins are names, removePlugins are constructors)', () => {
 			let plugins = new PluginCollection( editor, availablePlugins );
 			let plugins = new PluginCollection( editor, availablePlugins );
 
 
 			return plugins.load( [ 'A', 'B', 'C' ], [ PluginA ] )
 			return plugins.load( [ 'A', 'B', 'C' ], [ PluginA ] )
@@ -306,6 +306,20 @@ describe( 'PluginCollection', () => {
 				} );
 				} );
 		} );
 		} );
 
 
+		it( 'should load chosen plugins (plugins are names, removePlugins contains an anonymous plugin)', () => {
+			class AnonymousPlugin extends Plugin {}
+
+			let plugins = new PluginCollection( editor, [ AnonymousPlugin ].concat( availablePlugins ) );
+
+			return plugins.load( [ AnonymousPlugin, 'A', 'B' ], [ AnonymousPlugin ] )
+				.then( () => {
+					expect( getPlugins( plugins ).length ).to.equal( 2 );
+
+					expect( plugins.get( PluginA ) ).to.be.an.instanceof( PluginA );
+					expect( plugins.get( PluginB ) ).to.be.an.instanceof( PluginB );
+				} );
+		} );
+
 		it( 'should reject when loaded plugin requires not allowed plugins', () => {
 		it( 'should reject when loaded plugin requires not allowed plugins', () => {
 			let logSpy = testUtils.sinon.stub( log, 'error' );
 			let logSpy = testUtils.sinon.stub( log, 'error' );
 			let plugins = new PluginCollection( editor, availablePlugins );
 			let plugins = new PluginCollection( editor, availablePlugins );