瀏覽代碼

Merge pull request #159 from ckeditor/t/121

Extended test case for loading plugins in PluginCollection.
Piotrek Koszuliński 9 年之前
父節點
當前提交
c00248bbe6
共有 1 個文件被更改,包括 21 次插入1 次删除
  1. 21 1
      tests/plugincollection.js

+ 21 - 1
tests/plugincollection.js

@@ -15,7 +15,7 @@ import CKEditorError from '/ckeditor5/utils/ckeditorerror.js';
 import log from '/ckeditor5/utils/log.js';
 
 let editor;
-let PluginA, PluginB, PluginC, PluginD, PluginE, PluginF, PluginG;
+let PluginA, PluginB, PluginC, PluginD, PluginE, PluginF, PluginG, PluginH, PluginI;
 class TestError extends Error {}
 
 testUtils.createSinonSandbox();
@@ -28,11 +28,14 @@ before( () => {
 	PluginE = createPlugin( 'E' );
 	PluginF = createPlugin( 'F' );
 	PluginG = createPlugin( 'G', Creator );
+	PluginH = createPlugin( 'H' );
+	PluginI = createPlugin( 'I' );
 
 	PluginC.requires = [ PluginB ];
 	PluginD.requires = [ PluginA, PluginC ];
 	PluginF.requires = [ PluginE ];
 	PluginE.requires = [ PluginF ];
+	PluginH.requires = [ PluginI ];
 
 	editor = new Editor( document.body.appendChild( document.createElement( 'div' ) ) );
 } );
@@ -67,6 +70,14 @@ moduleUtils.define( 'G/G', () => {
 	return PluginG;
 } );
 
+moduleUtils.define( 'H/H', () => {
+	return PluginH;
+} );
+
+moduleUtils.define( 'I/I', () => {
+	return PluginI;
+} );
+
 // Erroneous cases.
 
 moduleUtils.define( 'X/X', () => {
@@ -175,6 +186,15 @@ describe( 'load', () => {
 			} );
 	} );
 
+	it( 'should make plugin available to get by name when plugin was loaded as dependency first', () => {
+		let plugins = new PluginCollection( editor );
+
+		return plugins.load( [ 'H', 'I' ] )
+			.then( () => {
+				expect( plugins.get( 'I' ) ).to.be.instanceof( PluginI );
+			} );
+	} );
+
 	it( 'should set the `editor` property on loaded plugins', () => {
 		let plugins = new PluginCollection( editor );