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

Tests: Add simple cell merge & split simulation tests in downcast converter.

Maciej Gołaszewski 7 лет назад
Родитель
Сommit
3d74a29873
1 измененных файлов с 43 добавлено и 3 удалено
  1. 43 3
      packages/ckeditor5-table/tests/converters/downcasttable.js

+ 43 - 3
packages/ckeditor5-table/tests/converters/downcasttable.js

@@ -501,6 +501,49 @@ describe( 'downcastTable()', () => {
 				]
 			] ) );
 		} );
+
+		it( 'split cell simulation - simple', () => {
+			setModelData( model, modelTable( [
+				[ '11', '12' ],
+				[ '21', '22' ]
+			] ) );
+
+			const table = root.getChild( 0 );
+
+			model.change( writer => {
+				const firstRow = table.getChild( 0 );
+				const secondRow = table.getChild( 1 );
+
+				writer.insertElement( 'tableCell', firstRow, 1 );
+				writer.setAttribute( 'colspan', 2, secondRow.getChild( 0 ) );
+			} );
+
+			expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal( viewTable( [
+				[ '11', '', '12' ],
+				[ { colspan: 2, contents: '21' }, '22' ]
+			] ) );
+		} );
+
+		it( 'merge simulation - simple', () => {
+			setModelData( model, modelTable( [
+				[ '11', '12' ],
+				[ '21', '22' ]
+			] ) );
+
+			const table = root.getChild( 0 );
+
+			model.change( writer => {
+				const firstRow = table.getChild( 0 );
+
+				writer.setAttribute( 'colspan', 2, firstRow.getChild( 0 ) );
+				writer.remove( firstRow.getChild( 1 ) );
+			} );
+
+			expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal( viewTable( [
+				[ { colspan: 2, contents: '11' } ],
+				[ '21', '22' ]
+			] ) );
+		} );
 	} );
 
 	describe( 'table attribute change', () => {
@@ -670,7 +713,4 @@ describe( 'downcastTable()', () => {
 			);
 		} );
 	} );
-
-	describe( 'cell split', () => {
-	} );
 } );