浏览代码

Other: Review table commands names & add tests for TableEditing.

Maciej Gołaszewski 7 年之前
父节点
当前提交
078414a02d
共有 2 个文件被更改,包括 68 次插入4 次删除
  1. 4 4
      packages/ckeditor5-table/src/tableediting.js
  2. 64 0
      packages/ckeditor5-table/tests/tableediting.js

+ 4 - 4
packages/ckeditor5-table/src/tableediting.js

@@ -109,10 +109,10 @@ export default class TablesEditing extends Plugin {
 		editor.commands.add( 'splitCellVertically', new SplitCellCommand( editor, { direction: 'vertically' } ) );
 		editor.commands.add( 'splitCellHorizontally', new SplitCellCommand( editor, { direction: 'horizontally' } ) );
 
-		editor.commands.add( 'mergeRight', new MergeCellCommand( editor, { direction: 'right' } ) );
-		editor.commands.add( 'mergeLeft', new MergeCellCommand( editor, { direction: 'left' } ) );
-		editor.commands.add( 'mergeDown', new MergeCellCommand( editor, { direction: 'down' } ) );
-		editor.commands.add( 'mergeUp', new MergeCellCommand( editor, { direction: 'up' } ) );
+		editor.commands.add( 'mergeCellRight', new MergeCellCommand( editor, { direction: 'right' } ) );
+		editor.commands.add( 'mergeCellLeft', new MergeCellCommand( editor, { direction: 'left' } ) );
+		editor.commands.add( 'mergeCellDown', new MergeCellCommand( editor, { direction: 'down' } ) );
+		editor.commands.add( 'mergeCellUp', new MergeCellCommand( editor, { direction: 'up' } ) );
 
 		editor.commands.add( 'setTableHeaders', new SetTableHeadersCommand( editor ) );
 

+ 64 - 0
packages/ckeditor5-table/tests/tableediting.js

@@ -10,6 +10,14 @@ import { getCode } from '@ckeditor/ckeditor5-utils/src/keyboard';
 
 import TableEditing from '../src/tableediting';
 import { formatTable, formattedModelTable, modelTable } from './_utils/utils';
+import InsertRowCommand from '../src/commands/insertrowcommand';
+import InsertTableCommand from '../src/commands/inserttablecommand';
+import InsertColumnCommand from '../src/commands/insertcolumncommand';
+import RemoveRowCommand from '../src/commands/removerowcommand';
+import RemoveColumnCommand from '../src/commands/removecolumncommand';
+import SplitCellCommand from '../src/commands/splitcellcommand';
+import MergeCellCommand from '../src/commands/mergecellcommand';
+import SetTableHeadersCommand from '../src/commands/settableheaderscommand';
 
 describe( 'TableEditing', () => {
 	let editor, model;
@@ -33,6 +41,62 @@ describe( 'TableEditing', () => {
 	it( 'should set proper schema rules', () => {
 	} );
 
+	it( 'adds insertTable command', () => {
+		expect( editor.commands.get( 'insertTable' ) ).to.be.instanceOf( InsertTableCommand );
+	} );
+
+	it( 'adds insertRowAbove command', () => {
+		expect( editor.commands.get( 'insertRowAbove' ) ).to.be.instanceOf( InsertRowCommand );
+	} );
+
+	it( 'adds insertRowBelow command', () => {
+		expect( editor.commands.get( 'insertRowBelow' ) ).to.be.instanceOf( InsertRowCommand );
+	} );
+
+	it( 'adds insertColumnBefore command', () => {
+		expect( editor.commands.get( 'insertColumnBefore' ) ).to.be.instanceOf( InsertColumnCommand );
+	} );
+
+	it( 'adds insertColumnAfter command', () => {
+		expect( editor.commands.get( 'insertColumnAfter' ) ).to.be.instanceOf( InsertColumnCommand );
+	} );
+
+	it( 'adds removeRow command', () => {
+		expect( editor.commands.get( 'removeRow' ) ).to.be.instanceOf( RemoveRowCommand );
+	} );
+
+	it( 'adds removeColumn command', () => {
+		expect( editor.commands.get( 'removeColumn' ) ).to.be.instanceOf( RemoveColumnCommand );
+	} );
+
+	it( 'adds splitCellVertically command', () => {
+		expect( editor.commands.get( 'splitCellVertically' ) ).to.be.instanceOf( SplitCellCommand );
+	} );
+
+	it( 'adds splitCellHorizontally command', () => {
+		expect( editor.commands.get( 'splitCellHorizontally' ) ).to.be.instanceOf( SplitCellCommand );
+	} );
+
+	it( 'adds mergeCellRight command', () => {
+		expect( editor.commands.get( 'mergeCellRight' ) ).to.be.instanceOf( MergeCellCommand );
+	} );
+
+	it( 'adds mergeCellLeft command', () => {
+		expect( editor.commands.get( 'mergeCellLeft' ) ).to.be.instanceOf( MergeCellCommand );
+	} );
+
+	it( 'adds mergeCellDown command', () => {
+		expect( editor.commands.get( 'mergeCellDown' ) ).to.be.instanceOf( MergeCellCommand );
+	} );
+
+	it( 'adds mergeCellUp command', () => {
+		expect( editor.commands.get( 'mergeCellUp' ) ).to.be.instanceOf( MergeCellCommand );
+	} );
+
+	it( 'adds setTableHeaders command', () => {
+		expect( editor.commands.get( 'setTableHeaders' ) ).to.be.instanceOf( SetTableHeadersCommand );
+	} );
+
 	describe( 'conversion in data pipeline', () => {
 		describe( 'model to view', () => {
 			it( 'should create tbody section', () => {