|
|
@@ -8,13 +8,13 @@
|
|
|
import ClassicTestEditor from 'tests/core/_utils/classictesteditor.js';
|
|
|
import Heading from 'ckeditor5/heading/heading.js';
|
|
|
import HeadingEngine from 'ckeditor5/heading/headingengine.js';
|
|
|
-import ListDropdown from 'ckeditor5/ui/dropdown/list/listdropdown.js';
|
|
|
+import DropdownView from 'ckeditor5/ui/dropdown/dropdownview.js';
|
|
|
import testUtils from 'tests/core/_utils/utils.js';
|
|
|
|
|
|
testUtils.createSinonSandbox();
|
|
|
|
|
|
describe( 'Heading', () => {
|
|
|
- let editor, controller;
|
|
|
+ let editor, dropdown;
|
|
|
|
|
|
beforeEach( () => {
|
|
|
const editorElement = document.createElement( 'div' );
|
|
|
@@ -26,7 +26,7 @@ describe( 'Heading', () => {
|
|
|
} )
|
|
|
.then( newEditor => {
|
|
|
editor = newEditor;
|
|
|
- controller = editor.ui.featureComponents.create( 'headings' );
|
|
|
+ dropdown = editor.ui.featureComponents.create( 'headings' );
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
@@ -43,18 +43,17 @@ describe( 'Heading', () => {
|
|
|
} );
|
|
|
|
|
|
it( 'should register formats feature component', () => {
|
|
|
- const controller = editor.ui.featureComponents.create( 'headings' );
|
|
|
+ const dropdown = editor.ui.featureComponents.create( 'headings' );
|
|
|
|
|
|
- expect( controller ).to.be.instanceOf( ListDropdown );
|
|
|
+ expect( dropdown ).to.be.instanceOf( DropdownView );
|
|
|
} );
|
|
|
|
|
|
it( 'should execute format command on model execute event', () => {
|
|
|
const executeSpy = testUtils.sinon.spy( editor, 'execute' );
|
|
|
- const controller = editor.ui.featureComponents.create( 'headings' );
|
|
|
- const model = controller.model;
|
|
|
+ const dropdown = editor.ui.featureComponents.create( 'headings' );
|
|
|
|
|
|
- model.id = 'foo';
|
|
|
- model.fire( 'execute' );
|
|
|
+ dropdown.formatId = 'foo';
|
|
|
+ dropdown.fire( 'execute' );
|
|
|
|
|
|
sinon.assert.calledOnce( executeSpy );
|
|
|
sinon.assert.calledWithExactly( executeSpy, 'heading', { formatId: 'foo' } );
|
|
|
@@ -62,32 +61,30 @@ describe( 'Heading', () => {
|
|
|
|
|
|
it( 'should focus view after command execution', () => {
|
|
|
const focusSpy = testUtils.sinon.spy( editor.editing.view, 'focus' );
|
|
|
- const controller = editor.ui.featureComponents.create( 'headings' );
|
|
|
- const model = controller.model;
|
|
|
+ const dropdown = editor.ui.featureComponents.create( 'headings' );
|
|
|
|
|
|
- model.fire( 'execute' );
|
|
|
+ dropdown.fire( 'execute' );
|
|
|
|
|
|
sinon.assert.calledOnce( focusSpy );
|
|
|
} );
|
|
|
|
|
|
describe( 'model to command binding', () => {
|
|
|
- let model, command;
|
|
|
+ let command;
|
|
|
|
|
|
beforeEach( () => {
|
|
|
- model = controller.model;
|
|
|
command = editor.commands.get( 'heading' );
|
|
|
} );
|
|
|
|
|
|
it( 'isEnabled', () => {
|
|
|
- expect( model.isEnabled ).to.be.true;
|
|
|
+ expect( dropdown.buttonView.isEnabled ).to.be.true;
|
|
|
command.isEnabled = false;
|
|
|
- expect( model.isEnabled ).to.be.false;
|
|
|
+ expect( dropdown.buttonView.isEnabled ).to.be.false;
|
|
|
} );
|
|
|
|
|
|
it( 'label', () => {
|
|
|
- expect( model.label ).to.equal( 'Paragraph' );
|
|
|
+ expect( dropdown.buttonView.label ).to.equal( 'Paragraph' );
|
|
|
command.value = command.formats[ 1 ];
|
|
|
- expect( model.label ).to.equal( 'Heading 1' );
|
|
|
+ expect( dropdown.buttonView.label ).to.equal( 'Heading 1' );
|
|
|
} );
|
|
|
} );
|
|
|
} );
|