|
|
@@ -448,6 +448,59 @@ describe( 'PluginCollection', () => {
|
|
|
expect( plugins.get( SomePlugin ) ).to.be.instanceOf( SomePlugin );
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'warns if plugin cannot be retrieved by name', () => {
|
|
|
+ const logSpy = testUtils.sinon.stub( log, 'warn' );
|
|
|
+
|
|
|
+ const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
+
|
|
|
+ return plugins.load( [] ).then( () => {
|
|
|
+ const plugin = plugins.get( 'foo' );
|
|
|
+
|
|
|
+ expect( plugin ).to.be.undefined;
|
|
|
+
|
|
|
+ expect( logSpy.calledOnce ).to.equal( true );
|
|
|
+ expect( logSpy.firstCall.args[ 0 ] ).to.match( /^plugincollection-plugin-not-loaded:/ );
|
|
|
+ expect( logSpy.firstCall.args[ 1 ] ).to.deep.equal( { plugin: 'foo' } );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'warns if plugin cannot be retrieved by class', () => {
|
|
|
+ class SomePlugin extends Plugin {}
|
|
|
+ SomePlugin.pluginName = 'foo';
|
|
|
+
|
|
|
+ const logSpy = testUtils.sinon.stub( log, 'warn' );
|
|
|
+
|
|
|
+ const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
+
|
|
|
+ return plugins.load( [] ).then( () => {
|
|
|
+ const plugin = plugins.get( SomePlugin );
|
|
|
+
|
|
|
+ expect( plugin ).to.be.undefined;
|
|
|
+
|
|
|
+ expect( logSpy.calledOnce ).to.equal( true );
|
|
|
+ expect( logSpy.firstCall.args[ 0 ] ).to.match( /^plugincollection-plugin-not-loaded:/ );
|
|
|
+ expect( logSpy.firstCall.args[ 1 ] ).to.deep.equal( { plugin: 'foo' } );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'logs function (class) name if plugin cannot be retrieved by class', () => {
|
|
|
+ class SomePlugin extends Plugin {}
|
|
|
+
|
|
|
+ const logSpy = testUtils.sinon.stub( log, 'warn' );
|
|
|
+
|
|
|
+ const plugins = new PluginCollection( editor, availablePlugins );
|
|
|
+
|
|
|
+ return plugins.load( [] ).then( () => {
|
|
|
+ const plugin = plugins.get( SomePlugin );
|
|
|
+
|
|
|
+ expect( plugin ).to.be.undefined;
|
|
|
+
|
|
|
+ expect( logSpy.calledOnce ).to.equal( true );
|
|
|
+ expect( logSpy.firstCall.args[ 0 ] ).to.match( /^plugincollection-plugin-not-loaded:/ );
|
|
|
+ expect( logSpy.firstCall.args[ 1 ] ).to.deep.equal( { plugin: 'SomePlugin' } );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'destroy()', () => {
|