Parcourir la source

Tests: Added more detailed unit tests for remove rows command and multi cell table selection.

Marek Lewandowski il y a 5 ans
Parent
commit
42e2163fc3
1 fichiers modifiés avec 63 ajouts et 15 suppressions
  1. 63 15
      packages/ckeditor5-table/tests/commands/removerowcommand.js

+ 63 - 15
packages/ckeditor5-table/tests/commands/removerowcommand.js

@@ -105,23 +105,71 @@ describe( 'RemoveRowCommand', () => {
 			] ) );
 		} );
 
-		it( 'should remove multiple rows if more than one row is selected', () => {
-			setData( model, modelTable( [
-				[ '00', '01' ],
-				[ '10', '11' ],
-				[ '20', '21' ]
-			] ) );
-
-			const tableSelection = editor.plugins.get( TableSelection );
-			const modelRoot = model.document.getRoot();
-			tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 1, 0 ] ) );
-			tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 2, 0 ] ) );
+		describe( 'multiple rows selection', () => {
+			it( 'should properly remove when middle 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, 1, 0 ] ) );
+				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 2, 0 ] ) );
+
+				command.execute();
+
+				assertEqualMarkup( getData( model ), modelTable( [
+					[ '00', '01' ],
+					[ '[]30', '31' ]
+				] ) );
+			} );
 
-			command.execute();
+			it( 'should properly remove when beginning 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, 0, 0 ] ) );
+				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 0 ] ) );
+
+				command.execute();
+
+				assertEqualMarkup( getData( model ), modelTable( [
+					[ '[]20', '21' ],
+					[ '30', '31' ]
+				] ) );
+			} );
 
-			assertEqualMarkup( getData( model ), modelTable( [
-				[ '00', '01[]' ]
-			] ) );
+			// 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 remove a given row from a table start', () => {