Browse Source

Tests: Add missing tests for TableUI.

Maciej Gołaszewski 7 years ago
parent
commit
6f00328892
1 changed files with 51 additions and 0 deletions
  1. 51 0
      packages/ckeditor5-table/tests/tableui.js

+ 51 - 0
packages/ckeditor5-table/tests/tableui.js

@@ -138,6 +138,23 @@ describe( 'TableUI', () => {
 			expect( items.get( 2 ).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( 'insertRowBelow' );
+		} );
 	} );
 
 	describe( 'tableColumn button', () => {
@@ -196,6 +213,23 @@ describe( 'TableUI', () => {
 			expect( items.get( 2 ).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( 'insertColumnBefore' );
+		} );
 	} );
 
 	describe( 'mergeCell button', () => {
@@ -261,5 +295,22 @@ describe( 'TableUI', () => {
 
 			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( 'mergeCellUp' );
+		} );
 	} );
 } );