8
0
Просмотр исходного кода

Add more cases to MergeCellsCommand#isEnabled checks.

Maciej Gołaszewski 5 лет назад
Родитель
Сommit
05b5159d37
1 измененных файлов с 36 добавлено и 8 удалено
  1. 36 8
      packages/ckeditor5-table/tests/commands/mergecellscommand.js

+ 36 - 8
packages/ckeditor5-table/tests/commands/mergecellscommand.js

@@ -238,25 +238,39 @@ describe( 'MergeCellsCommand', () => {
 			expect( command.isEnabled ).to.be.false;
 		} );
 
+		it( 'should be true if selection has cells only from column headers - rows in body section', () => {
+			setData( model, modelTable( [
+				[ '00[]', '01', '02', '03' ],
+				[ '10', '11', '12', '13' ]
+			], { headingColumns: 2 } ) );
+
+			tableSelection._setCellSelection(
+				root.getNodeByPath( [ 0, 0, 0 ] ),
+				root.getNodeByPath( [ 0, 1, 1 ] )
+			);
+
+			expect( command.isEnabled ).to.be.true;
+		} );
+
 		it( 'should be false if selection has cells from column headers and other cells - rows in body section', () => {
 			setData( model, modelTable( [
-				[ '00[]', '01' ],
-				[ '10', '11' ]
-			], { headingColumns: 1 } ) );
+				[ '00[]', '01', '02', '03' ],
+				[ '10', '11', '12', '13' ]
+			], { headingColumns: 2 } ) );
 
 			tableSelection._setCellSelection(
 				root.getNodeByPath( [ 0, 0, 0 ] ),
-				root.getNodeByPath( [ 0, 0, 1 ] )
+				root.getNodeByPath( [ 0, 1, 2 ] )
 			);
 
 			expect( command.isEnabled ).to.be.false;
 		} );
 
-		it( 'should be true if selection has cells from column headers and other cells - rows in header section', () => {
+		it( 'should be true if selection has cells only from column headers - rows in header section', () => {
 			setData( model, modelTable( [
-				[ '00[]', '01' ],
-				[ '10', '11' ]
-			], { headingColumns: 1, headingRows: 1 } ) );
+				[ '00[]', '01', '02', '03' ],
+				[ '10', '11', '12', '13' ]
+			], { headingColumns: 2, headingRows: 1 } ) );
 
 			tableSelection._setCellSelection(
 				root.getNodeByPath( [ 0, 0, 0 ] ),
@@ -265,6 +279,20 @@ describe( 'MergeCellsCommand', () => {
 
 			expect( command.isEnabled ).to.be.true;
 		} );
+
+		it( 'should be false if selection has cells only from column headers and other cells - rows in header section', () => {
+			setData( model, modelTable( [
+				[ '00[]', '01', '02', '03' ],
+				[ '10', '11', '12', '13' ]
+			], { headingColumns: 2, headingRows: 1 } ) );
+
+			tableSelection._setCellSelection(
+				root.getNodeByPath( [ 0, 0, 0 ] ),
+				root.getNodeByPath( [ 0, 0, 2 ] )
+			);
+
+			expect( command.isEnabled ).to.be.false;
+		} );
 	} );
 
 	describe( 'execute()', () => {