|
@@ -9,6 +9,10 @@ import Editor from '/ckeditor5/editor.js';
|
|
|
import Bold from '/ckeditor5/basic-styles/bold.js';
|
|
import Bold from '/ckeditor5/basic-styles/bold.js';
|
|
|
import BoldEngine from '/ckeditor5/basic-styles/boldengine.js';
|
|
import BoldEngine from '/ckeditor5/basic-styles/boldengine.js';
|
|
|
import ClassicCreator from '/ckeditor5/creator-classic/classiccreator.js';
|
|
import ClassicCreator from '/ckeditor5/creator-classic/classiccreator.js';
|
|
|
|
|
+import ButtonController from '/ckeditor5/ui/button/button.js';
|
|
|
|
|
+import testUtils from '/tests/ckeditor5/_utils/utils.js';
|
|
|
|
|
+
|
|
|
|
|
+testUtils.createSinonSandbox();
|
|
|
|
|
|
|
|
describe( 'Bold', () => {
|
|
describe( 'Bold', () => {
|
|
|
let editor;
|
|
let editor;
|
|
@@ -30,4 +34,39 @@ describe( 'Bold', () => {
|
|
|
it( 'should load BoldEngine', () => {
|
|
it( 'should load BoldEngine', () => {
|
|
|
expect( editor.plugins.get( BoldEngine ) ).to.be.instanceOf( BoldEngine );
|
|
expect( editor.plugins.get( BoldEngine ) ).to.be.instanceOf( BoldEngine );
|
|
|
} );
|
|
} );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should register bold feature component', () => {
|
|
|
|
|
+ const controller = editor.ui.featureComponents.create( 'bold' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( controller ).to.be.instanceOf( ButtonController );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should execute bold command on model execute event', () => {
|
|
|
|
|
+ const executeSpy = testUtils.sinon.spy( editor, 'execute' );
|
|
|
|
|
+ const controller = editor.ui.featureComponents.create( 'bold' );
|
|
|
|
|
+ const model = controller.model;
|
|
|
|
|
+
|
|
|
|
|
+ model.fire( 'execute' );
|
|
|
|
|
+
|
|
|
|
|
+ sinon.assert.calledOnce( executeSpy );
|
|
|
|
|
+ sinon.assert.calledWithExactly( executeSpy, 'bold' );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should bind model to bold command', () => {
|
|
|
|
|
+ const controller = editor.ui.featureComponents.create( 'bold' );
|
|
|
|
|
+ const model = controller.model;
|
|
|
|
|
+ const command = editor.commands.get( 'bold' );
|
|
|
|
|
+
|
|
|
|
|
+ expect( model.isOn ).to.be.false;
|
|
|
|
|
+ expect( command.value ).to.be.false;
|
|
|
|
|
+
|
|
|
|
|
+ expect( model.isEnabled ).to.be.true;
|
|
|
|
|
+ expect( command.isEnabled ).to.be.true;
|
|
|
|
|
+
|
|
|
|
|
+ command.value = true;
|
|
|
|
|
+ expect( model.isOn ).to.equal( true );
|
|
|
|
|
+
|
|
|
|
|
+ command.isEnabled = false;
|
|
|
|
|
+ expect( model.isEnabled ).to.equal( false );
|
|
|
|
|
+ } );
|
|
|
} );
|
|
} );
|