Преглед на файлове

Tests: Added unit test for column removal command availability in case of multiple cells selected.

Marek Lewandowski преди 5 години
родител
ревизия
a14724d595
променени са 1 файла, в които са добавени 16 реда и са изтрити 1 реда
  1. 16 1
      packages/ckeditor5-table/tests/commands/removecolumncommand.js

+ 16 - 1
packages/ckeditor5-table/tests/commands/removecolumncommand.js

@@ -7,6 +7,7 @@ import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltestedit
 import { getData, setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 import RemoveColumnCommand from '../../src/commands/removecolumncommand';
+import TableSelection from '../../src/tableselection';
 import { defaultConversion, defaultSchema, modelTable } from '../_utils/utils';
 import TableUtils from '../../src/tableutils';
 import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
@@ -17,7 +18,7 @@ describe( 'RemoveColumnCommand', () => {
 	beforeEach( () => {
 		return ModelTestEditor
 			.create( {
-				plugins: [ TableUtils ]
+				plugins: [ TableUtils, TableSelection ]
 			} )
 			.then( newEditor => {
 				editor = newEditor;
@@ -43,6 +44,20 @@ describe( 'RemoveColumnCommand', () => {
 			expect( command.isEnabled ).to.be.true;
 		} );
 
+		it( 'should be true if selection contains multiple cells', () => {
+			setData( model, modelTable( [
+				[ '00', '01' ],
+				[ '10', '11' ]
+			] ) );
+
+			const tableSelection = editor.plugins.get( TableSelection );
+			const modelRoot = model.document.getRoot();
+			tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
+			tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 0, 1 ] ) );
+
+			expect( command.isEnabled ).to.be.true;
+		} );
+
 		it( 'should be false if selection is inside table with one column only', () => {
 			setData( model, modelTable( [
 				[ '00' ],