|
|
@@ -38,53 +38,58 @@ describe( 'Heading', () => {
|
|
|
expect( editor.plugins.get( Heading ) ).to.be.instanceOf( Heading );
|
|
|
} );
|
|
|
|
|
|
- it( 'should load FormatsEngine', () => {
|
|
|
+ it( 'should load HeadingEngine', () => {
|
|
|
expect( editor.plugins.get( HeadingEngine ) ).to.be.instanceOf( HeadingEngine );
|
|
|
} );
|
|
|
|
|
|
- it( 'should register formats feature component', () => {
|
|
|
- const dropdown = editor.ui.featureComponents.create( 'headings' );
|
|
|
+ describe( 'init()', () => {
|
|
|
+ it( 'should register formats feature component', () => {
|
|
|
+ const dropdown = editor.ui.featureComponents.create( 'headings' );
|
|
|
|
|
|
- expect( dropdown ).to.be.instanceOf( DropdownView );
|
|
|
- } );
|
|
|
+ expect( dropdown ).to.be.instanceOf( DropdownView );
|
|
|
+ expect( dropdown.buttonView.isEnabled ).to.be.true;
|
|
|
+ expect( dropdown.buttonView.isOn ).to.be.undefined;
|
|
|
+ expect( dropdown.buttonView.label ).to.equal( 'Paragraph' );
|
|
|
+ } );
|
|
|
|
|
|
- it( 'should execute format command on model execute event', () => {
|
|
|
- const executeSpy = testUtils.sinon.spy( editor, 'execute' );
|
|
|
- const dropdown = editor.ui.featureComponents.create( 'headings' );
|
|
|
+ it( 'should execute format command on model execute event', () => {
|
|
|
+ const executeSpy = testUtils.sinon.spy( editor, 'execute' );
|
|
|
+ const dropdown = editor.ui.featureComponents.create( 'headings' );
|
|
|
|
|
|
- dropdown.formatId = 'foo';
|
|
|
- dropdown.fire( 'execute' );
|
|
|
+ dropdown.formatId = 'foo';
|
|
|
+ dropdown.fire( 'execute' );
|
|
|
|
|
|
- sinon.assert.calledOnce( executeSpy );
|
|
|
- sinon.assert.calledWithExactly( executeSpy, 'heading', { formatId: 'foo' } );
|
|
|
- } );
|
|
|
+ sinon.assert.calledOnce( executeSpy );
|
|
|
+ sinon.assert.calledWithExactly( executeSpy, 'heading', { formatId: 'foo' } );
|
|
|
+ } );
|
|
|
|
|
|
- it( 'should focus view after command execution', () => {
|
|
|
- const focusSpy = testUtils.sinon.spy( editor.editing.view, 'focus' );
|
|
|
- const dropdown = editor.ui.featureComponents.create( 'headings' );
|
|
|
+ it( 'should focus view after command execution', () => {
|
|
|
+ const focusSpy = testUtils.sinon.spy( editor.editing.view, 'focus' );
|
|
|
+ const dropdown = editor.ui.featureComponents.create( 'headings' );
|
|
|
|
|
|
- dropdown.fire( 'execute' );
|
|
|
+ dropdown.fire( 'execute' );
|
|
|
|
|
|
- sinon.assert.calledOnce( focusSpy );
|
|
|
- } );
|
|
|
+ sinon.assert.calledOnce( focusSpy );
|
|
|
+ } );
|
|
|
|
|
|
- describe( 'model to command binding', () => {
|
|
|
- let command;
|
|
|
+ describe( 'model to command binding', () => {
|
|
|
+ let command;
|
|
|
|
|
|
- beforeEach( () => {
|
|
|
- command = editor.commands.get( 'heading' );
|
|
|
- } );
|
|
|
+ beforeEach( () => {
|
|
|
+ command = editor.commands.get( 'heading' );
|
|
|
+ } );
|
|
|
|
|
|
- it( 'isEnabled', () => {
|
|
|
- expect( dropdown.buttonView.isEnabled ).to.be.true;
|
|
|
- command.isEnabled = false;
|
|
|
- expect( dropdown.buttonView.isEnabled ).to.be.false;
|
|
|
- } );
|
|
|
+ it( 'isEnabled', () => {
|
|
|
+ expect( dropdown.buttonView.isEnabled ).to.be.true;
|
|
|
+ command.isEnabled = false;
|
|
|
+ expect( dropdown.buttonView.isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
|
|
|
- it( 'label', () => {
|
|
|
- expect( dropdown.buttonView.label ).to.equal( 'Paragraph' );
|
|
|
- command.value = command.formats[ 1 ];
|
|
|
- expect( dropdown.buttonView.label ).to.equal( 'Heading 1' );
|
|
|
+ it( 'label', () => {
|
|
|
+ expect( dropdown.buttonView.label ).to.equal( 'Paragraph' );
|
|
|
+ command.value = command.formats[ 1 ];
|
|
|
+ expect( dropdown.buttonView.label ).to.equal( 'Heading 1' );
|
|
|
+ } );
|
|
|
} );
|
|
|
} );
|
|
|
} );
|