Răsfoiți Sursa

Use TableEditing in InsertRowCommand tests.

Maciej Gołaszewski 5 ani în urmă
părinte
comite
019f0c6d9a
1 a modificat fișierele cu 68 adăugiri și 19 ștergeri
  1. 68 19
      packages/ckeditor5-table/tests/commands/insertrowcommand.js

+ 68 - 19
packages/ckeditor5-table/tests/commands/insertrowcommand.js

@@ -5,11 +5,13 @@
 
 
 import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor';
 import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor';
 import HorizontalLineEditing from '@ckeditor/ckeditor5-horizontal-line/src/horizontallineediting';
 import HorizontalLineEditing from '@ckeditor/ckeditor5-horizontal-line/src/horizontallineediting';
+import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 import { getData, setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { getData, setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 
 import InsertRowCommand from '../../src/commands/insertrowcommand';
 import InsertRowCommand from '../../src/commands/insertrowcommand';
+import TableEditing from '../../src/tableediting';
 import TableSelection from '../../src/tableselection';
 import TableSelection from '../../src/tableselection';
-import { assertSelectedCells, defaultConversion, defaultSchema, modelTable } from '../_utils/utils';
+import { assertSelectedCells, modelTable } from '../_utils/utils';
 import TableUtils from '../../src/tableutils';
 import TableUtils from '../../src/tableutils';
 import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 
@@ -19,14 +21,11 @@ describe( 'InsertRowCommand', () => {
 	beforeEach( () => {
 	beforeEach( () => {
 		return ModelTestEditor
 		return ModelTestEditor
 			.create( {
 			.create( {
-				plugins: [ TableUtils, TableSelection, HorizontalLineEditing ]
+				plugins: [ Paragraph, TableEditing, TableUtils, TableSelection, HorizontalLineEditing ]
 			} )
 			} )
 			.then( newEditor => {
 			.then( newEditor => {
 				editor = newEditor;
 				editor = newEditor;
 				model = editor.model;
 				model = editor.model;
-
-				defaultSchema( model.schema );
-				defaultConversion( editor.conversion );
 			} );
 			} );
 	} );
 	} );
 
 
@@ -119,54 +118,104 @@ describe( 'InsertRowCommand', () => {
 			} );
 			} );
 
 
 			it( 'should expand rowspan of a cell that overlaps inserted rows', () => {
 			it( 'should expand rowspan of a cell that overlaps inserted rows', () => {
+				// +----+----+----+----+
+				// | 00      | 02 | 03 |
+				// +----+----+----+----+ <-- heading rows
+				// | 10      | 12 | 13 |
+				// +         +----+----+
+				// |         | 22 | 23 |
+				// +----+----+----+----+
+				//                     ^-- heading columns
 				setData( model, modelTable( [
 				setData( model, modelTable( [
-					[ { colspan: 2, contents: '00' }, '02', '03' ],
-					[ { colspan: 2, rowspan: 4, contents: '10[]' }, '12', '13' ],
+					[ { contents: '00', colspan: 2 }, '02', '03' ],
+					[ { contents: '10[]', colspan: 2, rowspan: 2 }, '12', '13' ],
 					[ '22', '23' ]
 					[ '22', '23' ]
 				], { headingColumns: 3, headingRows: 1 } ) );
 				], { headingColumns: 3, headingRows: 1 } ) );
 
 
 				command.execute();
 				command.execute();
 
 
+				// +----+----+----+----+
+				// | 00      | 02 | 03 |
+				// +----+----+----+----+ <-- heading rows
+				// | 10      | 12 | 13 |
+				// +         +----+----+
+				// |         |    |    |
+				// +         +----+----+
+				// |         | 22 | 23 |
+				// +----+----+----+----+
+				//                     ^-- heading columns
 				assertEqualMarkup( getData( model ), modelTable( [
 				assertEqualMarkup( getData( model ), modelTable( [
-					[ { colspan: 2, contents: '00' }, '02', '03' ],
-					[ { colspan: 2, rowspan: 5, contents: '10[]' }, '12', '13' ],
+					[ { contents: '00', colspan: 2 }, '02', '03' ],
+					[ { contents: '10[]', colspan: 2, rowspan: 3 }, '12', '13' ],
 					[ '', '' ],
 					[ '', '' ],
 					[ '22', '23' ]
 					[ '22', '23' ]
 				], { headingColumns: 3, headingRows: 1 } ) );
 				], { headingColumns: 3, headingRows: 1 } ) );
 			} );
 			} );
 
 
 			it( 'should not expand rowspan of a cell that does not overlaps inserted rows', () => {
 			it( 'should not expand rowspan of a cell that does not overlaps inserted rows', () => {
+				// +----+----+----+
+				// | 00 | 01 | 02 |
+				// +    +----+----+
+				// |    | 11 | 12 |
+				// +----+----+----+ <-- heading rows
+				// | 20 | 21 | 22 |
+				// +----+----+----+
 				setData( model, modelTable( [
 				setData( model, modelTable( [
-					[ { rowspan: 2, contents: '00' }, '01', '02' ],
+					[ { contents: '00', rowspan: 2 }, '01', '02' ],
 					[ '11[]', '12' ],
 					[ '11[]', '12' ],
 					[ '20', '21', '22' ]
 					[ '20', '21', '22' ]
-				], { headingColumns: 3, headingRows: 1 } ) );
+				], { headingRows: 2 } ) );
 
 
 				command.execute();
 				command.execute();
 
 
+				// +----+----+----+
+				// | 00 | 01 | 02 |
+				// +    +----+----+
+				// |    | 11 | 12 |
+				// +----+----+----+ <-- heading rows
+				// |    |    |    |
+				// +----+----+----+
+				// | 20 | 21 | 22 |
+				// +----+----+----+
 				assertEqualMarkup( getData( model ), modelTable( [
 				assertEqualMarkup( getData( model ), modelTable( [
-					[ { rowspan: 2, contents: '00' }, '01', '02' ],
+					[ { contents: '00', rowspan: 2 }, '01', '02' ],
 					[ '11[]', '12' ],
 					[ '11[]', '12' ],
 					[ '', '', '' ],
 					[ '', '', '' ],
 					[ '20', '21', '22' ]
 					[ '20', '21', '22' ]
-				], { headingColumns: 3, headingRows: 1 } ) );
+				], { headingRows: 2 } ) );
 			} );
 			} );
 
 
 			it( 'should properly calculate columns if next row has colspans', () => {
 			it( 'should properly calculate columns if next row has colspans', () => {
+				// +----+----+----+
+				// | 00 | 01 | 02 |
+				// +    +----+----+
+				// |    | 11 | 12 |
+				// +----+----+----+ <-- heading rows
+				// | 20           |
+				// +----+----+----+
 				setData( model, modelTable( [
 				setData( model, modelTable( [
-					[ { rowspan: 2, contents: '00' }, '01', '02' ],
+					[ { contents: '00', rowspan: 2 }, '01', '02' ],
 					[ '11[]', '12' ],
 					[ '11[]', '12' ],
-					[ { colspan: 3, contents: '20' } ]
-				], { headingColumns: 3, headingRows: 1 } ) );
+					[ { contents: '20', colspan: 3 } ]
+				], { headingRows: 2 } ) );
 
 
 				command.execute();
 				command.execute();
 
 
+				// +----+----+----+
+				// | 00 | 01 | 02 |
+				// +    +----+----+
+				// |    | 11 | 12 |
+				// +----+----+----+ <-- heading rows
+				// |    |    |    |
+				// +----+----+----+
+				// | 20           |
+				// +----+----+----+
 				assertEqualMarkup( getData( model ), modelTable( [
 				assertEqualMarkup( getData( model ), modelTable( [
-					[ { rowspan: 2, contents: '00' }, '01', '02' ],
+					[ { contents: '00', rowspan: 2 }, '01', '02' ],
 					[ '11[]', '12' ],
 					[ '11[]', '12' ],
 					[ '', '', '' ],
 					[ '', '', '' ],
-					[ { colspan: 3, contents: '20' } ]
-				], { headingColumns: 3, headingRows: 1 } ) );
+					[ { contents: '20', colspan: 3 } ]
+				], { headingRows: 2 } ) );
 			} );
 			} );
 
 
 			it( 'should insert rows at the end of a table', () => {
 			it( 'should insert rows at the end of a table', () => {