Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
CC to 100%.
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarwrobel committed Dec 3, 2019
1 parent 785520b commit e4b63bb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/plugincollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export default class PluginCollection {

if ( PluginConstructor.isContextPlugin && !RequiredPluginConstructor.isContextPlugin ) {
throw new CKEditorError(
'plugincollection-context-required: Context plugin can not require plugin which is not context plugin',
'plugincollection-context-required: Context plugin can not require plugin which is not a context plugin',
null,
{ plugin: RequiredPluginConstructor.name, requiredBy: PluginConstructor.name }
);
Expand Down
20 changes: 20 additions & 0 deletions tests/plugincollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Editor from '../src/editor/editor';
import PluginCollection from '../src/plugincollection';
import Plugin from '../src/plugin';
import ContextPlugin from '../src/contextplugin';
import { expectToThrowCKEditorError, assertCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';

let editor, availablePlugins;
Expand Down Expand Up @@ -439,6 +440,25 @@ describe( 'PluginCollection', () => {
expect( plugins.get( PluginB ) ).to.equal( externalPlugins.get( PluginB ) ).to.instanceof( PluginB );
expect( plugins.get( PluginC ) ).to.instanceof( PluginC );
} );

it( 'should reject when context plugin requires non-context plugin', async () => {
class ContextPluginA extends ContextPlugin {}
ContextPluginA.requires = [ PluginA ];

const plugins = new PluginCollection( editor, [] );

let error;
const consoleErrorStub = sinon.stub( console, 'error' );

try {
await plugins.init( [ ContextPluginA ] );
} catch ( err ) {
error = err;
}

assertCKEditorError( error, /^plugincollection-context-required:/, null );
sinon.assert.calledOnce( consoleErrorStub );
} );
} );

describe( 'get()', () => {
Expand Down

0 comments on commit e4b63bb

Please sign in to comment.