瀏覽代碼

Add test for alignment attribute conversion in data pipeline.

Maciej Gołaszewski 6 年之前
父節點
當前提交
97b1c7b422
共有 1 個文件被更改,包括 29 次插入0 次删除
  1. 29 0
      packages/ckeditor5-table/tests/converters/downcast.js

+ 29 - 0
packages/ckeditor5-table/tests/converters/downcast.js

@@ -147,6 +147,35 @@ describe( 'downcast converters', () => {
 			) );
 			) );
 		} );
 		} );
 
 
+		it( 'should create table with block content (attribute on paragraph)', () => {
+			editor.conversion.attributeToAttribute(
+				{
+					model: { key: 'alignment', values: [ 'right', 'center', 'justify' ] },
+					view: {
+						right: { key: 'style', value: { 'text-align': 'right' } },
+						center: { key: 'style', value: { 'text-align': 'center' } },
+						justify: { key: 'style', value: { 'text-align': 'justify' } }
+					}
+				}
+			);
+
+			setModelData( model, modelTable( [
+				[ '<paragraph alignment="right">00</paragraph>' ]
+			] ) );
+
+			expect( formatTable( getViewData( viewDocument, { withoutSelection: true } ) ) ).to.equal( formatTable(
+				'<figure class="table">' +
+					'<table>' +
+						'<tbody>' +
+							'<tr>' +
+								'<td><p style="text-align:right">00</p></td>' +
+							'</tr>' +
+						'</tbody>' +
+					'</table>' +
+				'</figure>'
+			) );
+		} );
+
 		it( 'should be possible to overwrite', () => {
 		it( 'should be possible to overwrite', () => {
 			editor.conversion.elementToElement( { model: 'tableRow', view: 'tr', converterPriority: 'high' } );
 			editor.conversion.elementToElement( { model: 'tableRow', view: 'tr', converterPriority: 'high' } );
 			editor.conversion.elementToElement( { model: 'tableCell', view: 'td', converterPriority: 'high' } );
 			editor.conversion.elementToElement( { model: 'tableCell', view: 'td', converterPriority: 'high' } );