|
|
@@ -47,7 +47,7 @@ describe( 'TableUI', () => {
|
|
|
return editor.destroy();
|
|
|
} );
|
|
|
|
|
|
- describe( 'insertTable button', () => {
|
|
|
+ describe( 'insertTable dropdown', () => {
|
|
|
let insertTable;
|
|
|
|
|
|
beforeEach( () => {
|
|
|
@@ -157,7 +157,7 @@ describe( 'TableUI', () => {
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
- describe( 'tableColumn button', () => {
|
|
|
+ describe( 'tableColumn dropdown', () => {
|
|
|
let dropdown;
|
|
|
|
|
|
beforeEach( () => {
|
|
|
@@ -232,7 +232,7 @@ describe( 'TableUI', () => {
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
- describe( 'mergeCell button', () => {
|
|
|
+ describe( 'mergeCell dropdown', () => {
|
|
|
let dropdown;
|
|
|
|
|
|
beforeEach( () => {
|
|
|
@@ -313,4 +313,72 @@ describe( 'TableUI', () => {
|
|
|
expect( spy.args[ 0 ][ 0 ] ).to.equal( 'mergeCellUp' );
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ describe( 'splitCell dropdown', () => {
|
|
|
+ let dropdown;
|
|
|
+
|
|
|
+ beforeEach( () => {
|
|
|
+ dropdown = editor.ui.componentFactory.create( 'splitCell' );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'have button with proper properties set', () => {
|
|
|
+ expect( dropdown ).to.be.instanceOf( DropdownView );
|
|
|
+
|
|
|
+ const button = dropdown.buttonView;
|
|
|
+
|
|
|
+ expect( button.isOn ).to.be.false;
|
|
|
+ expect( button.tooltip ).to.be.true;
|
|
|
+ expect( button.label ).to.equal( 'Split cell' );
|
|
|
+ expect( button.icon ).to.match( /<svg / );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should have proper items in panel', () => {
|
|
|
+ const listView = dropdown.listView;
|
|
|
+
|
|
|
+ const labels = listView.items.map( ( { label } ) => label );
|
|
|
+
|
|
|
+ expect( labels ).to.deep.equal( [ 'Split cell vertically', 'Split cell horizontally' ] );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should bind items in panel to proper commands', () => {
|
|
|
+ const items = dropdown.listView.items;
|
|
|
+
|
|
|
+ const splitCellVerticallyCommand = editor.commands.get( 'splitCellVertically' );
|
|
|
+ const splitCellHorizontallyCommand = editor.commands.get( 'splitCellHorizontally' );
|
|
|
+
|
|
|
+ splitCellVerticallyCommand.isEnabled = true;
|
|
|
+ splitCellHorizontallyCommand.isEnabled = true;
|
|
|
+
|
|
|
+ expect( items.get( 0 ).isEnabled ).to.be.true;
|
|
|
+ expect( items.get( 1 ).isEnabled ).to.be.true;
|
|
|
+ expect( dropdown.buttonView.isEnabled ).to.be.true;
|
|
|
+
|
|
|
+ splitCellVerticallyCommand.isEnabled = false;
|
|
|
+
|
|
|
+ expect( items.get( 0 ).isEnabled ).to.be.false;
|
|
|
+ expect( dropdown.buttonView.isEnabled ).to.be.true;
|
|
|
+
|
|
|
+ splitCellHorizontallyCommand.isEnabled = false;
|
|
|
+
|
|
|
+ expect( items.get( 1 ).isEnabled ).to.be.false;
|
|
|
+ expect( dropdown.buttonView.isEnabled ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should focus view after command execution', () => {
|
|
|
+ const focusSpy = testUtils.sinon.spy( editor.editing.view, 'focus' );
|
|
|
+
|
|
|
+ dropdown.listView.items.get( 0 ).fire( 'execute' );
|
|
|
+
|
|
|
+ sinon.assert.calledOnce( focusSpy );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'executes command when it\'s executed', () => {
|
|
|
+ const spy = sinon.stub( editor, 'execute' );
|
|
|
+
|
|
|
+ dropdown.listView.items.get( 0 ).fire( 'execute' );
|
|
|
+
|
|
|
+ expect( spy.calledOnce ).to.be.true;
|
|
|
+ expect( spy.args[ 0 ][ 0 ] ).to.equal( 'splitCellVertically' );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
} );
|