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

Merge pull request #31 from ckeditor/t/ckeditor5-table/163

Tests: Add integration tests for images in tables.
Piotrek Koszuliński 7 лет назад
Родитель
Сommit
14d7f246e4
1 измененных файлов с 178 добавлено и 2 удалено
  1. 178 2
      packages/ckeditor5-block-quote/tests/integration.js

+ 178 - 2
packages/ckeditor5-block-quote/tests/integration.js

@@ -395,6 +395,54 @@ describe( 'BlockQuote integration', () => {
 				'</blockQuote>'
 			);
 		} );
+
+		it( 'wraps paragraph+image', () => {
+			setModelData( model,
+				'<paragraph>[foo</paragraph><image><caption>foo</caption></image>]'
+			);
+
+			editor.execute( 'blockQuote' );
+
+			expect( getModelData( model ) ).to.equal(
+				'<blockQuote><paragraph>[foo</paragraph><image><caption>foo</caption></image>]</blockQuote>'
+			);
+		} );
+
+		it( 'unwraps paragraph+image', () => {
+			setModelData( model,
+				'<blockQuote><paragraph>[foo</paragraph><image><caption>foo</caption></image>]</blockQuote>'
+			);
+
+			editor.execute( 'blockQuote' );
+
+			expect( getModelData( model ) ).to.equal(
+				'<paragraph>[foo</paragraph><image><caption>foo</caption></image>]'
+			);
+		} );
+
+		it( 'wraps image+paragraph', () => {
+			setModelData( model,
+				'[<image><caption>foo</caption></image><paragraph>foo]</paragraph>'
+			);
+
+			editor.execute( 'blockQuote' );
+
+			expect( getModelData( model ) ).to.equal(
+				'<blockQuote>[<image><caption>foo</caption></image><paragraph>foo]</paragraph></blockQuote>'
+			);
+		} );
+
+		it( 'unwraps image+paragraph', () => {
+			setModelData( model,
+				'[<image><caption>foo</caption></image><paragraph>foo]</paragraph>'
+			);
+
+			editor.execute( 'blockQuote' );
+
+			expect( getModelData( model ) ).to.equal(
+				'<blockQuote>[<image><caption>foo</caption></image><paragraph>foo]</paragraph></blockQuote>'
+			);
+		} );
 	} );
 
 	// When blockQuote with a paragraph was pasted into a list item, the item contained the paragraph. It was invalid.
@@ -444,7 +492,7 @@ describe( 'BlockQuote integration', () => {
 			);
 		} );
 
-		it( 'wraps table cell paragraph', () => {
+		it( 'wraps paragraph in table cell', () => {
 			setModelData( model, '<table><tableRow><tableCell><paragraph>[]foo</paragraph></tableCell></tableRow></table>' );
 
 			editor.execute( 'blockQuote' );
@@ -454,7 +502,7 @@ describe( 'BlockQuote integration', () => {
 			);
 		} );
 
-		it( 'unwraps table cell paragraph', () => {
+		it( 'unwraps paragraph in table cell', () => {
 			setModelData(
 				model,
 				'<table><tableRow><tableCell><blockQuote><paragraph>[]foo</paragraph></blockQuote></tableCell></tableRow></table>'
@@ -466,5 +514,133 @@ describe( 'BlockQuote integration', () => {
 				'<table><tableRow><tableCell><paragraph>[]foo</paragraph></tableCell></tableRow></table>'
 			);
 		} );
+
+		it( 'wraps image in table cell', () => {
+			setModelData( model,
+				'<table>' +
+					'<tableRow>' +
+						'<tableCell>[<image><caption>foo</caption></image>]</tableCell>' +
+				'	</tableRow>' +
+				'</table>'
+			);
+
+			editor.execute( 'blockQuote' );
+
+			expect( getModelData( model ) ).to.equal(
+				'<table>' +
+					'<tableRow>' +
+						'<tableCell><blockQuote>[<image><caption>foo</caption></image>]</blockQuote></tableCell>' +
+					'</tableRow>' +
+				'</table>'
+			);
+		} );
+
+		it( 'unwraps image in table cell', () => {
+			setModelData( model,
+				'<table>' +
+					'<tableRow>' +
+						'<tableCell><blockQuote>[<image><caption>foo</caption></image>]</blockQuote></tableCell>' +
+					'</tableRow>' +
+				'</table>'
+			);
+
+			editor.execute( 'blockQuote' );
+
+			expect( getModelData( model ) ).to.equal(
+				'<table>' +
+					'<tableRow>' +
+						'<tableCell>[<image><caption>foo</caption></image>]</tableCell>' +
+					'</tableRow>' +
+				'</table>'
+			);
+		} );
+
+		it( 'wraps paragraph+image in table cell', () => {
+			setModelData( model,
+				'<table>' +
+					'<tableRow>' +
+						'<tableCell><paragraph>[foo</paragraph><image><caption>foo</caption></image>]</tableCell>' +
+					'</tableRow>' +
+				'</table>'
+			);
+
+			editor.execute( 'blockQuote' );
+
+			expect( getModelData( model ) ).to.equal(
+				'<table>' +
+					'<tableRow>' +
+						'<tableCell>' +
+							'<blockQuote><paragraph>[foo</paragraph><image><caption>foo</caption></image>]</blockQuote>' +
+						'</tableCell>' +
+					'</tableRow>' +
+				'</table>'
+			);
+		} );
+
+		it( 'unwraps paragraph+image in table cell', () => {
+			setModelData( model,
+				'<table>' +
+					'<tableRow>' +
+						'<tableCell>' +
+							'<blockQuote><paragraph>[foo</paragraph><image><caption>foo</caption></image>]</blockQuote>' +
+						'</tableCell>' +
+					'</tableRow>' +
+				'</table>'
+			);
+
+			editor.execute( 'blockQuote' );
+
+			expect( getModelData( model ) ).to.equal(
+				'<table>' +
+					'<tableRow>' +
+						'<tableCell><paragraph>[foo</paragraph><image><caption>foo</caption></image>]</tableCell>' +
+					'</tableRow>' +
+				'</table>'
+			);
+		} );
+
+		it( 'wraps image+paragraph in table cell', () => {
+			setModelData( model,
+				'<table>' +
+					'<tableRow>' +
+						'<tableCell>[<image><caption>foo</caption></image><paragraph>foo]</paragraph></tableCell>' +
+					'</tableRow>' +
+				'</table>'
+			);
+
+			editor.execute( 'blockQuote' );
+
+			expect( getModelData( model ) ).to.equal(
+				'<table>' +
+					'<tableRow>' +
+						'<tableCell>' +
+							'<blockQuote>[<image><caption>foo</caption></image><paragraph>foo]</paragraph></blockQuote>' +
+						'</tableCell>' +
+					'</tableRow>' +
+				'</table>'
+			);
+		} );
+
+		it( 'unwraps image+paragraph in table cell', () => {
+			setModelData( model,
+				'<table>' +
+					'<tableRow>' +
+						'<tableCell>[<image><caption>foo</caption></image><paragraph>foo]</paragraph></tableCell>' +
+					'</tableRow>' +
+				'</table>'
+			);
+
+			editor.execute( 'blockQuote' );
+
+			expect( getModelData( model ) ).to.equal(
+				'<table>' +
+				'<tableRow>' +
+				'<tableCell>' +
+				'<blockQuote>[<image><caption>foo</caption></image><paragraph>foo]</paragraph></blockQuote>' +
+				'</tableCell>' +
+				'</tableRow>' +
+				'</table>'
+			);
+		} );
 	} );
 } );