Browse Source

Tests: Cover more cases for removing empty tableRow after executing merge cell commands.

Maciej Gołaszewski 7 years ago
parent
commit
06d8645aae
1 changed files with 53 additions and 0 deletions
  1. 53 0
      packages/ckeditor5-table/tests/commands/mergecellcommand.js

+ 53 - 0
packages/ckeditor5-table/tests/commands/mergecellcommand.js

@@ -409,6 +409,25 @@ describe( 'MergeCellCommand', () => {
 					[ '20', '21' ]
 				] ) );
 			} );
+
+			it( 'should not reduce rowspan on cells above removed empty row when merging table cells ', () => {
+				setData( model, modelTable( [
+					[ { rowspan: 2, contents: '00' }, '01', '02' ],
+					[ '11', '12' ],
+					[ { rowspan: 2, contents: '20' }, '21[]', { rowspan: 3, contents: '22' } ],
+					[ '31' ],
+					[ '40', '41' ]
+				] ) );
+
+				command.execute();
+
+				expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
+					[ { rowspan: 2, contents: '00' }, '01', '02' ],
+					[ '11', '12' ],
+					[ '20', '[2131]', { rowspan: 2, contents: '22' } ],
+					[ '40', '41' ]
+				] ) );
+			} );
 		} );
 	} );
 
@@ -557,6 +576,40 @@ describe( 'MergeCellCommand', () => {
 					[ { colspan: 2, contents: '40' }, '42' ]
 				] ) );
 			} );
+
+			it( 'should remove empty row if merging table cells ', () => {
+				setData( model, modelTable( [
+					[ { rowspan: 2, contents: '00' }, '01', { rowspan: 3, contents: '02' } ],
+					[ '11[]' ],
+					[ '20', '21' ]
+				] ) );
+
+				command.execute();
+
+				expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
+					[ '00', '[0111]', { rowspan: 2, contents: '02' } ],
+					[ '20', '21' ]
+				] ) );
+			} );
+
+			it( 'should not reduce rowspan on cells above removed empty row when merging table cells ', () => {
+				setData( model, modelTable( [
+					[ { rowspan: 2, contents: '00' }, '01', '02' ],
+					[ '11', '12' ],
+					[ { rowspan: 2, contents: '20' }, '21', { rowspan: 3, contents: '22' } ],
+					[ '31[]' ],
+					[ '40', '41' ]
+				] ) );
+
+				command.execute();
+
+				expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
+					[ { rowspan: 2, contents: '00' }, '01', '02' ],
+					[ '11', '12' ],
+					[ '20', '[2131]', { rowspan: 2, contents: '22' } ],
+					[ '40', '41' ]
+				] ) );
+			} );
 		} );
 	} );
 } );