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

Tests: Added test coverage for removing rows with mixed header and regular row being removed.

Marek Lewandowski 5 лет назад
Родитель
Сommit
a77f11b66e
1 измененных файлов с 59 добавлено и 19 удалено
  1. 59 19
      packages/ckeditor5-table/tests/commands/removerowcommand.js

+ 59 - 19
packages/ckeditor5-table/tests/commands/removerowcommand.js

@@ -127,6 +127,29 @@ describe( 'RemoveRowCommand', () => {
 				] ) );
 			} );
 
+			// This test is blocked by (#6370).
+			//
+			// it( 'should properly remove when tailing rows are selected', () => {
+			// 	setData( model, modelTable( [
+			// 		[ '00', '01' ],
+			// 		[ '10', '11' ],
+			// 		[ '20', '21' ],
+			// 		[ '30', '31' ]
+			// 	] ) );
+
+			// 	const tableSelection = editor.plugins.get( TableSelection );
+			// 	const modelRoot = model.document.getRoot();
+			// 	tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 2, 0 ] ) );
+			// 	tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 36, 0 ] ) );
+
+			// 	command.execute();
+
+			// 	assertEqualMarkup( getData( model ), modelTable( [
+			// 		[ '00', '01' ],
+			// 		[ '10', '11[]' ]
+			// 	] ) );
+			// } );
+
 			it( 'should properly remove when beginning rows are selected', () => {
 				setData( model, modelTable( [
 					[ '00', '01' ],
@@ -148,28 +171,45 @@ describe( 'RemoveRowCommand', () => {
 				] ) );
 			} );
 
-			// This test is blocked by (#6370).
-			//
-			// it( 'should properly remove when tailing rows are selected', () => {
-			// 	setData( model, modelTable( [
-			// 		[ '00', '01' ],
-			// 		[ '10', '11' ],
-			// 		[ '20', '21' ],
-			// 		[ '30', '31' ]
-			// 	] ) );
+			it( 'should support removing multiple headings', () => {
+				setData( model, modelTable( [
+					[ '00', '01' ],
+					[ '10', '11' ],
+					[ '20', '21' ],
+					[ '30', '31' ]
+				], { headingRows: 3 } ) );
 
-			// 	const tableSelection = editor.plugins.get( TableSelection );
-			// 	const modelRoot = model.document.getRoot();
-			// 	tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 2, 0 ] ) );
-			// 	tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 36, 0 ] ) );
+				const tableSelection = editor.plugins.get( TableSelection );
+				const modelRoot = model.document.getRoot();
+				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
+				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 0 ] ) );
 
-			// 	command.execute();
+				command.execute();
 
-			// 	assertEqualMarkup( getData( model ), modelTable( [
-			// 		[ '00', '01' ],
-			// 		[ '10', '11[]' ]
-			// 	] ) );
-			// } );
+				assertEqualMarkup( getData( model ), modelTable( [
+					[ '[]20', '21' ],
+					[ '30', '31' ]
+				], { headingRows: 1 } ) );
+			} );
+
+			it( 'should support removing mixed heading and cell rows', () => {
+				setData( model, modelTable( [
+					[ '00', '01' ],
+					[ '10', '11' ],
+					[ '20', '21' ]
+				], { headingRows: 1 } ) );
+
+				const tableSelection = editor.plugins.get( TableSelection );
+				const modelRoot = model.document.getRoot();
+				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
+				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 0 ] ) );
+
+				command.execute();
+
+				assertEqualMarkup( getData( model ), modelTable( [
+					[ '[]20', '21' ]
+				] ) );
+			} );
 		} );
 
 		it( 'should remove a given row from a table start', () => {