|
|
@@ -77,7 +77,7 @@ describe( 'PluginCollection', () => {
|
|
|
it( 'should not fail when trying to load 0 plugins (empty array)', () => {
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [] )
|
|
|
+ return plugins.init( [] )
|
|
|
.then( () => {
|
|
|
expect( getPlugins( plugins ) ).to.be.empty;
|
|
|
} );
|
|
|
@@ -86,7 +86,7 @@ describe( 'PluginCollection', () => {
|
|
|
it( 'should add collection items for loaded plugins', () => {
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ PluginA, PluginB ] )
|
|
|
+ return plugins.init( [ PluginA, PluginB ] )
|
|
|
.then( () => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 2 );
|
|
|
|
|
|
@@ -98,7 +98,7 @@ describe( 'PluginCollection', () => {
|
|
|
it( 'should add collection items for loaded plugins using plugin names', () => {
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ 'A', 'B' ] )
|
|
|
+ return plugins.init( [ 'A', 'B' ] )
|
|
|
.then( () => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 2 );
|
|
|
|
|
|
@@ -111,7 +111,7 @@ describe( 'PluginCollection', () => {
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
const spy = sinon.spy( plugins, '_add' );
|
|
|
|
|
|
- return plugins.load( [ PluginA, PluginC ] )
|
|
|
+ return plugins.init( [ PluginA, PluginC ] )
|
|
|
.then( loadedPlugins => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 3 );
|
|
|
|
|
|
@@ -126,7 +126,7 @@ describe( 'PluginCollection', () => {
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
const spy = sinon.spy( plugins, '_add' );
|
|
|
|
|
|
- return plugins.load( [ 'J' ] )
|
|
|
+ return plugins.init( [ 'J' ] )
|
|
|
.then( loadedPlugins => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 3 );
|
|
|
|
|
|
@@ -141,7 +141,7 @@ describe( 'PluginCollection', () => {
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
const spy = sinon.spy( plugins, '_add' );
|
|
|
|
|
|
- return plugins.load( [ PluginA, PluginB, PluginC ] )
|
|
|
+ return plugins.init( [ PluginA, PluginB, PluginC ] )
|
|
|
.then( loadedPlugins => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 3 );
|
|
|
|
|
|
@@ -156,7 +156,7 @@ describe( 'PluginCollection', () => {
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
const spy = sinon.spy( plugins, '_add' );
|
|
|
|
|
|
- return plugins.load( [ PluginD ] )
|
|
|
+ return plugins.init( [ PluginD ] )
|
|
|
.then( loadedPlugins => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 4 );
|
|
|
|
|
|
@@ -172,7 +172,7 @@ describe( 'PluginCollection', () => {
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
const spy = sinon.spy( plugins, '_add' );
|
|
|
|
|
|
- return plugins.load( [ PluginA, PluginE ] )
|
|
|
+ return plugins.init( [ PluginA, PluginE ] )
|
|
|
.then( loadedPlugins => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 3 );
|
|
|
|
|
|
@@ -187,7 +187,7 @@ describe( 'PluginCollection', () => {
|
|
|
it( 'should load grand child classes', () => {
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ PluginG ] )
|
|
|
+ return plugins.init( [ PluginG ] )
|
|
|
.then( () => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 1 );
|
|
|
} );
|
|
|
@@ -198,7 +198,7 @@ describe( 'PluginCollection', () => {
|
|
|
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ Y ] )
|
|
|
+ return plugins.init( [ Y ] )
|
|
|
.then( () => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 1 );
|
|
|
} );
|
|
|
@@ -211,7 +211,7 @@ describe( 'PluginCollection', () => {
|
|
|
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ pluginAsFunction ] )
|
|
|
+ return plugins.init( [ pluginAsFunction ] )
|
|
|
.then( () => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 1 );
|
|
|
} );
|
|
|
@@ -230,7 +230,7 @@ describe( 'PluginCollection', () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return plugins.load( [ PluginA, PluginB, pluginAsFunction, Y ] )
|
|
|
+ return plugins.init( [ PluginA, PluginB, pluginAsFunction, Y ] )
|
|
|
.then( () => {
|
|
|
expect( plugins.get( PluginA ).editor ).to.equal( editor );
|
|
|
expect( plugins.get( PluginB ).editor ).to.equal( editor );
|
|
|
@@ -244,8 +244,8 @@ describe( 'PluginCollection', () => {
|
|
|
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ PluginA, PluginX, PluginB ] )
|
|
|
- // Throw here, so if by any chance plugins.load() was resolved correctly catch() will be stil executed.
|
|
|
+ return plugins.init( [ PluginA, PluginX, PluginB ] )
|
|
|
+ // Throw here, so if by any chance plugins.init() was resolved correctly catch() will be stil executed.
|
|
|
.then( () => {
|
|
|
throw new Error( 'Test error: this promise should not be resolved successfully' );
|
|
|
} )
|
|
|
@@ -263,8 +263,8 @@ describe( 'PluginCollection', () => {
|
|
|
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ 'NonExistentPlugin' ] )
|
|
|
- // Throw here, so if by any chance plugins.load() was resolved correctly catch() will be stil executed.
|
|
|
+ return plugins.init( [ 'NonExistentPlugin' ] )
|
|
|
+ // Throw here, so if by any chance plugins.init() was resolved correctly catch() will be stil executed.
|
|
|
.then( () => {
|
|
|
throw new Error( 'Test error: this promise should not be resolved successfully' );
|
|
|
} )
|
|
|
@@ -280,7 +280,7 @@ describe( 'PluginCollection', () => {
|
|
|
it( 'should load chosen plugins (plugins and removePlugins are constructors)', () => {
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ PluginA, PluginB, PluginC ], [ PluginA ] )
|
|
|
+ return plugins.init( [ PluginA, PluginB, PluginC ], [ PluginA ] )
|
|
|
.then( () => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 2 );
|
|
|
|
|
|
@@ -292,7 +292,7 @@ describe( 'PluginCollection', () => {
|
|
|
it( 'should load chosen plugins (plugins are constructors, removePlugins are names)', () => {
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ PluginA, PluginB, PluginC ], [ 'A' ] )
|
|
|
+ return plugins.init( [ PluginA, PluginB, PluginC ], [ 'A' ] )
|
|
|
.then( () => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 2 );
|
|
|
|
|
|
@@ -304,7 +304,7 @@ describe( 'PluginCollection', () => {
|
|
|
it( 'should load chosen plugins (plugins and removePlugins are names)', () => {
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ 'A', 'B', 'C' ], [ 'A' ] )
|
|
|
+ return plugins.init( [ 'A', 'B', 'C' ], [ 'A' ] )
|
|
|
.then( () => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 2 );
|
|
|
|
|
|
@@ -316,7 +316,7 @@ describe( 'PluginCollection', () => {
|
|
|
it( 'should load chosen plugins (plugins are names, removePlugins are constructors)', () => {
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ 'A', 'B', 'C' ], [ PluginA ] )
|
|
|
+ return plugins.init( [ 'A', 'B', 'C' ], [ PluginA ] )
|
|
|
.then( () => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 2 );
|
|
|
|
|
|
@@ -330,7 +330,7 @@ describe( 'PluginCollection', () => {
|
|
|
|
|
|
const plugins = new PluginCollection( editor, [ AnonymousPlugin ].concat( availablePlugins ) );
|
|
|
|
|
|
- return plugins.load( [ AnonymousPlugin, 'A', 'B' ], [ AnonymousPlugin ] )
|
|
|
+ return plugins.init( [ AnonymousPlugin, 'A', 'B' ], [ AnonymousPlugin ] )
|
|
|
.then( () => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 2 );
|
|
|
|
|
|
@@ -343,8 +343,8 @@ describe( 'PluginCollection', () => {
|
|
|
const logSpy = testUtils.sinon.stub( log, 'error' );
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ PluginA, PluginB, PluginC, PluginD ], [ PluginA, PluginB ] )
|
|
|
- // Throw here, so if by any chance plugins.load() was resolved correctly catch() will be stil executed.
|
|
|
+ return plugins.init( [ PluginA, PluginB, PluginC, PluginD ], [ PluginA, PluginB ] )
|
|
|
+ // Throw here, so if by any chance plugins.init() was resolved correctly catch() will be stil executed.
|
|
|
.then( () => {
|
|
|
throw new Error( 'Test error: this promise should not be resolved successfully' );
|
|
|
} )
|
|
|
@@ -360,7 +360,7 @@ describe( 'PluginCollection', () => {
|
|
|
const logSpy = testUtils.sinon.stub( log, 'warn' );
|
|
|
const plugins = new PluginCollection( editor );
|
|
|
|
|
|
- return plugins.load( [ PluginFoo, AnotherPluginFoo ] )
|
|
|
+ return plugins.init( [ PluginFoo, AnotherPluginFoo ] )
|
|
|
.then( () => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 2 );
|
|
|
|
|
|
@@ -384,7 +384,7 @@ describe( 'PluginCollection', () => {
|
|
|
const logSpy = testUtils.sinon.stub( log, 'warn' );
|
|
|
const plugins = new PluginCollection( editor );
|
|
|
|
|
|
- return plugins.load( [ PluginFoo ] )
|
|
|
+ return plugins.init( [ PluginFoo ] )
|
|
|
.then( () => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 2 );
|
|
|
|
|
|
@@ -405,7 +405,7 @@ describe( 'PluginCollection', () => {
|
|
|
const logSpy = testUtils.sinon.stub( log, 'warn' );
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ 'Foo', AnotherPluginFoo ] )
|
|
|
+ return plugins.init( [ 'Foo', AnotherPluginFoo ] )
|
|
|
.then( () => {
|
|
|
expect( getPlugins( plugins ).length ).to.equal( 2 );
|
|
|
|
|
|
@@ -428,7 +428,7 @@ describe( 'PluginCollection', () => {
|
|
|
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ SomePlugin ] )
|
|
|
+ return plugins.init( [ SomePlugin ] )
|
|
|
.then( () => {
|
|
|
expect( plugins.get( SomePlugin ) ).to.be.instanceOf( SomePlugin );
|
|
|
} );
|
|
|
@@ -442,7 +442,7 @@ describe( 'PluginCollection', () => {
|
|
|
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ SomePlugin ] )
|
|
|
+ return plugins.init( [ SomePlugin ] )
|
|
|
.then( () => {
|
|
|
expect( plugins.get( 'foo/bar' ) ).to.be.instanceOf( SomePlugin );
|
|
|
expect( plugins.get( SomePlugin ) ).to.be.instanceOf( SomePlugin );
|
|
|
@@ -452,7 +452,7 @@ describe( 'PluginCollection', () => {
|
|
|
it( 'throws if plugin cannot be retrieved by name', () => {
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [] ).then( () => {
|
|
|
+ return plugins.init( [] ).then( () => {
|
|
|
expect( () => plugins.get( 'foo' ) )
|
|
|
.to.throw( CKEditorError, /^plugincollection-plugin-not-loaded:/ )
|
|
|
.with.deep.property( 'data', { plugin: 'foo' } );
|
|
|
@@ -465,7 +465,7 @@ describe( 'PluginCollection', () => {
|
|
|
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [] ).then( () => {
|
|
|
+ return plugins.init( [] ).then( () => {
|
|
|
expect( () => plugins.get( SomePlugin ) )
|
|
|
.to.throw( CKEditorError, /^plugincollection-plugin-not-loaded:/ )
|
|
|
.with.deep.property( 'data', { plugin: 'foo' } );
|
|
|
@@ -477,7 +477,7 @@ describe( 'PluginCollection', () => {
|
|
|
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [] ).then( () => {
|
|
|
+ return plugins.init( [] ).then( () => {
|
|
|
expect( () => plugins.get( SomePlugin ) )
|
|
|
.to.throw( CKEditorError, /^plugincollection-plugin-not-loaded:/ )
|
|
|
.with.deep.property( 'data', { plugin: 'SomePlugin' } );
|
|
|
@@ -504,13 +504,13 @@ describe( 'PluginCollection', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'returns true if plugins is loaded (retrieved by name)', () => {
|
|
|
- return plugins.load( [ PluginA ] ).then( () => {
|
|
|
+ return plugins.init( [ PluginA ] ).then( () => {
|
|
|
expect( plugins.has( 'A' ) ).to.be.true;
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
it( 'returns true if plugins is loaded (retrieved by class)', () => {
|
|
|
- return plugins.load( [ PluginA ] ).then( () => {
|
|
|
+ return plugins.init( [ PluginA ] ).then( () => {
|
|
|
expect( plugins.has( PluginA ) ).to.be.true;
|
|
|
} );
|
|
|
} );
|
|
|
@@ -522,7 +522,7 @@ describe( 'PluginCollection', () => {
|
|
|
|
|
|
const plugins = new PluginCollection( editor, [] );
|
|
|
|
|
|
- return plugins.load( [ PluginA, PluginB ] )
|
|
|
+ return plugins.init( [ PluginA, PluginB ] )
|
|
|
.then( () => {
|
|
|
destroySpyForPluginA = sinon.spy( plugins.get( PluginA ), 'destroy' );
|
|
|
destroySpyForPluginB = sinon.spy( plugins.get( PluginB ), 'destroy' );
|
|
|
@@ -566,7 +566,7 @@ describe( 'PluginCollection', () => {
|
|
|
|
|
|
const plugins = new PluginCollection( editor, [] );
|
|
|
|
|
|
- return plugins.load( [ AsynchronousPluginA, AsynchronousPluginB ] )
|
|
|
+ return plugins.init( [ AsynchronousPluginA, AsynchronousPluginB ] )
|
|
|
.then( () => plugins.destroy() )
|
|
|
.then( () => {
|
|
|
expect( destroyedPlugins ).to.contain( 'AsynchronousPluginB.destroy()' );
|
|
|
@@ -583,7 +583,7 @@ describe( 'PluginCollection', () => {
|
|
|
|
|
|
const plugins = new PluginCollection( editor, [] );
|
|
|
|
|
|
- return plugins.load( [ PluginA, FooPlugin ] )
|
|
|
+ return plugins.init( [ PluginA, FooPlugin ] )
|
|
|
.then( () => plugins.destroy() )
|
|
|
.then( destroyedPlugins => {
|
|
|
expect( destroyedPlugins.length ).to.equal( 1 );
|
|
|
@@ -608,7 +608,7 @@ describe( 'PluginCollection', () => {
|
|
|
|
|
|
const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
|
|
|
- return plugins.load( [ SomePlugin1, SomePlugin2 ] )
|
|
|
+ return plugins.init( [ SomePlugin1, SomePlugin2 ] )
|
|
|
.then( () => {
|
|
|
const pluginConstructors = Array.from( plugins )
|
|
|
.map( entry => entry[ 0 ] );
|