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

Added more toData method tests.

Szymon Kupś 9 лет назад
Родитель
Сommit
40a12fde54

+ 1 - 1
packages/ckeditor5-markdown-gfm/src/lib/to-markdown/converters.js

@@ -48,5 +48,5 @@ export default [
 
 			return hPrefix + ' ' + content;
 		}
-	},
+	}
 ];

+ 14 - 7
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/blockquotes.js

@@ -4,6 +4,7 @@
  */
 
 import MarkdownDataProcessor from '/ckeditor5/markdown-gfm/gfmdataprocessor.js';
+import DocumentFragment from '/ckeditor5/engine/view/documentfragment.js';
 import { stringify, parse } from '/tests/engine/_utils/view.js';
 
 describe( 'GFMDataProcessor', () => {
@@ -87,14 +88,20 @@ describe( 'GFMDataProcessor', () => {
 		} );
 
 		describe( 'toData', () => {
+			let viewFragment;
+
+			beforeEach( () => {
+				viewFragment = new DocumentFragment();
+			} );
+
 			it( 'should process single blockquotes', () => {
-				const viewFragment = parse( '<blockquote><p>foo bar</p></blockquote>' );
+				viewFragment.appendChildren( parse( '<blockquote><p>foo bar</p></blockquote>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '> foo bar' );
 			} );
 
 			it( 'should process nested blockquotes', () => {
-				const viewFragment = parse(
+				viewFragment.appendChildren( parse(
 					'<blockquote>' +
 						'<p>foo</p>' +
 						'<blockquote>' +
@@ -102,7 +109,7 @@ describe( 'GFMDataProcessor', () => {
 						'</blockquote>' +
 						'<p>foo</p>' +
 					'</blockquote>'
-				);
+				) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal(
 					'> foo\n' +
@@ -114,7 +121,7 @@ describe( 'GFMDataProcessor', () => {
 			} );
 
 			it( 'should process list within a blockquote', () => {
-				const viewFragment = parse(
+				viewFragment.appendChildren( parse(
 					'<blockquote>' +
 						'<p>A list within a blockquote:</p>' +
 						'<ul>' +
@@ -123,7 +130,7 @@ describe( 'GFMDataProcessor', () => {
 							'<li>asterisk 3</li>' +
 						'</ul>' +
 					'</blockquote>'
-				);
+				) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal(
 					'> A list within a blockquote:\n' +
@@ -135,7 +142,7 @@ describe( 'GFMDataProcessor', () => {
 			} );
 
 			it( 'should process blockquotes with code inside', () => {
-				const viewFragment = parse(
+				viewFragment.appendChildren( parse(
 					'<blockquote>' +
 						'<p>Example 1:</p>' +
 						'<pre>' +
@@ -151,7 +158,7 @@ describe( 'GFMDataProcessor', () => {
 						'</pre>' +
 					'</blockquote>',
 					{ sameSelectionCharacters: true }
-				);
+				) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal(
 					'> Example 1:\n' +

+ 10 - 3
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/code.js

@@ -4,6 +4,7 @@
  */
 
 import MarkdownDataProcessor from '/ckeditor5/markdown-gfm/gfmdataprocessor.js';
+import DocumentFragment from '/ckeditor5/engine/view/documentfragment.js';
 import { stringify, parse } from '/tests/engine/_utils/view.js';
 
 describe( 'GFMDataProcessor', () => {
@@ -171,20 +172,26 @@ describe( 'GFMDataProcessor', () => {
 		} );
 
 		describe( 'toData', () => {
+			let viewFragment;
+
+			beforeEach( () => {
+				viewFragment = new DocumentFragment();
+			} );
+
 			it( 'should process inline code', () => {
-				const viewFragment = parse( '<p>regular text and <code>inline code</code></p>' );
+				viewFragment.appendChildren( parse( '<p>regular text and <code>inline code</code></p>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( 'regular text and `inline code`' );
 			} );
 
 			it( 'should properly process code blocks', () => {
-				const viewFragment = parse( '<pre><code>code block</code></pre>' );
+				viewFragment.appendChildren( parse( '<pre><code>code block</code></pre>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '```\ncode block\n```' );
 			} );
 
 			it( 'should process code block with language name', () => {
-				const viewFragment = parse( '<pre><code class="lang-js">code block</code></pre>' );
+				viewFragment.appendChildren( parse( '<pre><code class="lang-js">code block</code></pre>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal(
 					'``` js\n' +

+ 9 - 2
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/del.js

@@ -4,6 +4,7 @@
  */
 
 import MarkdownDataProcessor from '/ckeditor5/markdown-gfm/gfmdataprocessor.js';
+import DocumentFragment from '/ckeditor5/engine/view/documentfragment.js';
 import { stringify, parse } from '/tests/engine/_utils/view.js';
 
 describe( 'GFMDataProcessor', () => {
@@ -29,14 +30,20 @@ describe( 'GFMDataProcessor', () => {
 		} );
 
 		describe( 'toData', () => {
+			let viewFragment;
+
+			beforeEach( () => {
+				viewFragment = new DocumentFragment();
+			} );
+
 			it( 'should process deleted text', () => {
-				const viewFragment = parse( '<p><del>deleted</del></p>' );
+				viewFragment.appendChildren( parse( '<p><del>deleted</del></p>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '~~deleted~~' );
 			} );
 
 			it( 'should process deleted inside text', () => {
-				const viewFragment = parse( '<p>This is <del>deleted content</del>.</p>' );
+				viewFragment.appendChildren( parse( '<p>This is <del>deleted content</del>.</p>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( 'This is ~~deleted content~~.' );
 			} );

+ 13 - 6
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/headers.js

@@ -4,6 +4,7 @@
  */
 
 import MarkdownDataProcessor from '/ckeditor5/markdown-gfm/gfmdataprocessor.js';
+import DocumentFragment from '/ckeditor5/engine/view/documentfragment.js';
 import { stringify, parse } from '/tests/engine/_utils/view.js';
 
 describe( 'GFMDataProcessor', () => {
@@ -71,38 +72,44 @@ describe( 'GFMDataProcessor', () => {
 		} );
 
 		describe( 'toData', () => {
+			let viewFragment;
+
+			beforeEach( () => {
+				viewFragment = new DocumentFragment();
+			} );
+
 			it( 'should process level 1 header', () => {
-				const viewFragment = parse( '<h1 id="level-1">Level 1</h1>' );
+				viewFragment.appendChildren( parse( '<h1 id="level-1">Level 1</h1>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '# Level 1' );
 			} );
 
 			it( 'should process level 2 header', () => {
-				const viewFragment = parse( '<h2 id="level-2">Level 2</h2>' );
+				viewFragment.appendChildren( parse( '<h2 id="level-2">Level 2</h2>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '## Level 2' );
 			} );
 
 			it( 'should process level 3 header', () => {
-				const viewFragment = parse( '<h3 id="level-3">Level 3</h3>' );
+				viewFragment.appendChildren( parse( '<h3 id="level-3">Level 3</h3>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '### Level 3' );
 			} );
 
 			it( 'should process level 4 header', () => {
-				const viewFragment = parse( '<h4 id="level-4">Level 4</h4>' );
+				viewFragment.appendChildren( parse( '<h4 id="level-4">Level 4</h4>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '#### Level 4' );
 			} );
 
 			it( 'should process level 5 header', () => {
-				const viewFragment = parse( '<h5 id="level-5">Level 5</h5>' );
+				viewFragment.appendChildren( parse( '<h5 id="level-5">Level 5</h5>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '##### Level 5' );
 			} );
 
 			it( 'should process level 6 header', () => {
-				const viewFragment = parse( '<h6 id="level-6">Level 6</h6>' );
+				viewFragment.appendChildren( parse( '<h6 id="level-6">Level 6</h6>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '###### Level 6' );
 			} );

+ 3 - 1
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/horizontal_rules.js

@@ -4,6 +4,7 @@
  */
 
 import MarkdownDataProcessor from '/ckeditor5/markdown-gfm/gfmdataprocessor.js';
+import DocumentFragment from '/ckeditor5/engine/view/documentfragment.js';
 import { stringify, parse } from '/tests/engine/_utils/view.js';
 
 describe( 'GFMDataProcessor', () => {
@@ -210,7 +211,8 @@ describe( 'GFMDataProcessor', () => {
 
 		describe( 'toData', () => {
 			it( 'should process horizontal rules', () => {
-				const viewFragment = parse( '<hr></hr>' );
+				const viewFragment = new DocumentFragment();
+				viewFragment.appendChildren( parse( '<hr></hr>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '* * *' );
 			} );

+ 24 - 13
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/links.js

@@ -4,6 +4,7 @@
  */
 
 import MarkdownDataProcessor from '/ckeditor5/markdown-gfm/gfmdataprocessor.js';
+import DocumentFragment from '/ckeditor5/engine/view/documentfragment.js';
 import { stringify, parse } from '/tests/engine/_utils/view.js';
 
 describe( 'GFMDataProcessor', () => {
@@ -343,68 +344,78 @@ describe( 'GFMDataProcessor', () => {
 		} );
 
 		describe( 'toData', () => {
+			let viewFragment;
+
+			beforeEach( () => {
+				viewFragment = new DocumentFragment();
+			} );
+
 			it( 'should process links', () => {
-				const viewFragment = parse( '<p>Link: <a href="http://example.com/">http://example.com/</a>.</p>' );
+				viewFragment.appendChildren( parse( '<p>Link: <a href="http://example.com/">http://example.com/</a>.</p>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( 'Link: [http://example.com/](http://example.com/).' );
 			} );
 
 			it( 'should process links with params', () => {
-				const viewFragment = parse(
+				viewFragment.appendChildren( parse(
 					'<p>' +
 						'Link: <a href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</a>.' +
-					'</p>' );
+					'</p>'
+				) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( 'Link: [http://example.com/?foo=1&bar=2](http://example.com/?foo=1&bar=2).' );
 			} );
 
 			it( 'should process links with titles', () => {
-				const viewFragment = parse(
+				viewFragment.appendChildren( parse(
 					'<p>' +
 					'Link: <a href="http://example.com/" title="Link title">example site</a>.' +
-					'</p>' );
+					'</p>'
+				) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( 'Link: [example site](http://example.com/ "Link title").' );
 			} );
 
 			it( 'should process links with spaces in URL', () => {
-				const viewFragment = parse(
+				viewFragment.appendChildren( parse(
 					'<p>' +
 					'Link: <a href="url/has space">example</a>.' +
-					'</p>' );
+					'</p>'
+				) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( 'Link: [example](url/has space).' );
 			} );
 
 			it( 'should process links with titles and spaces in URL', () => {
-				const viewFragment = parse(
+				viewFragment.appendChildren( parse(
 					'<p>' +
 					'Link: <a href="url/has space" title="Link title">example</a>.' +
-					'</p>' );
+					'</p>'
+				) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( 'Link: [example](url/has space "Link title").' );
 			} );
 
 			it( 'should process empty links #1', () => {
-				const viewFragment = parse( '<p><a>Empty</a></p>' );
+				viewFragment.appendChildren( parse( '<p><a>Empty</a></p>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '[Empty]()' );
 			} );
 
 			it( 'should process empty links #2', () => {
-				const viewFragment = parse( '<p><a></a></p>' );
+				viewFragment.appendChildren( parse( '<p><a></a></p>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '[]()' );
 			} );
 
 			it( 'should process empty links with title #1', () => {
-				const viewFragment = parse( '<p><a title="Link Title">Empty</a></p>' );
+				viewFragment.appendChildren( parse( '<p><a title="Link Title">Empty</a></p>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '[Empty]("Link Title")' );
 			} );
 
 			it( 'should process empty links with title #2', () => {
-				const viewFragment = parse( '<p><a title="Link Title"></a></p>' );
+				viewFragment.appendChildren( parse( '<p><a title="Link Title"></a></p>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '[]("Link Title")' );
 			} );

+ 11 - 29
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/lists.js

@@ -4,6 +4,7 @@
  */
 
 import MarkdownDataProcessor from '/ckeditor5/markdown-gfm/gfmdataprocessor.js';
+import DocumentFragment from '/ckeditor5/engine/view/documentfragment.js';
 import { stringify, parse } from '/tests/engine/_utils/view.js';
 
 describe( 'GFMDataProcessor', () => {
@@ -225,14 +226,20 @@ describe( 'GFMDataProcessor', () => {
 		} );
 
 		describe( 'toData', () => {
+			let viewFragment;
+
+			beforeEach( () => {
+				viewFragment = new DocumentFragment();
+			} );
+
 			it( 'should process unordered lists', () => {
-				const viewFragment = parse(
+				viewFragment.appendChildren( parse(
 					'<ul>' +
 						'<li>item 1</li>' +
 						'<li>item 2</li>' +
 						'<li>item 3</li>' +
 					'</ul>'
-				);
+				) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal(
 					'*   item 1\n' +
@@ -242,13 +249,13 @@ describe( 'GFMDataProcessor', () => {
 			} );
 
 			it( 'should process ordered lists', () => {
-				const viewFragment = parse(
+				viewFragment.appendChildren( parse(
 					'<ol>' +
 						'<li>item 1</li>' +
 						'<li>item 2</li>' +
 						'<li>item 3</li>' +
 					'</ol>'
-				);
+				) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal(
 					'1.  item 1\n' +
@@ -256,31 +263,6 @@ describe( 'GFMDataProcessor', () => {
 					'3.  item 3'
 				);
 			} );
-
-			// it( 'should process ordered list with multiple paragraphs in them', () => {
-			// 	const viewFragment = parse(
-			// 		'<ol>' +
-			// 			'<li>' +
-			// 				'<p>Item 1, p1</p>' +
-			// 				'<p>Item 1, p2<br></br>next line</p>' +
-			// 			'</li>' +
-			// 			'<li>' +
-			// 				'<p>Item 2.</p>' +
-			// 			'</li>' +
-			// 			'<li>' +
-			// 				'<p>Item 3.</p>' +
-			// 			'</li>' +
-			// 		'</ol>'
-			// 	);
-			//
-			// 	expect( dataProcessor.toData( viewFragment ) ).to.equal(
-			// 		'1.  Item 1, p1\n\n' +
-			// 		'    Item 1, p2\n' +
-			// 		'    next line\n\n' +
-			// 		'2.  Item 2.\n\n' +
-			// 		'3.  Item 3.'
-			// 	);
-			// } );
 		} );
 	} );
 } );

+ 57 - 3
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/paragraphs.js

@@ -4,7 +4,8 @@
  */
 
 import MarkdownDataProcessor from '/ckeditor5/markdown-gfm/gfmdataprocessor.js';
-import { stringify } from '/tests/engine/_utils/view.js';
+import DocumentFragment from '/ckeditor5/engine/view/documentfragment.js';
+import { stringify, parse } from '/tests/engine/_utils/view.js';
 
 describe( 'GFMDataProcessor', () => {
 	let dataProcessor;
@@ -22,9 +23,9 @@ describe( 'GFMDataProcessor', () => {
 			} );
 
 			it( 'multiline', () => {
-				const viewFragment = dataProcessor.toView( 'first\n    second\n   third' );
+				const viewFragment = dataProcessor.toView( 'first\nsecond\nthird' );
 
-				expect( stringify( viewFragment ) ).to.equal( '<p>first<br></br>    second<br></br>   third</p>' );
+				expect( stringify( viewFragment ) ).to.equal( '<p>first<br></br>second<br></br>third</p>' );
 			} );
 
 			it( 'with header after #1', () => {
@@ -57,5 +58,58 @@ describe( 'GFMDataProcessor', () => {
 				expect( stringify( viewFragment ) ).to.equal( '<p>single line</p><div>div element</div>' );
 			} );
 		} );
+
+		describe( 'toData', () => {
+			let viewFragment;
+
+			beforeEach( () => {
+				viewFragment = new DocumentFragment();
+			} );
+
+			it( 'should process single line paragraph', () => {
+				viewFragment.appendChildren( parse( '<p>single line paragraph</p>' ) );
+
+				expect( dataProcessor.toData( viewFragment ) ).to.equal( 'single line paragraph' );
+			} );
+
+			it( 'should process multi line paragraph', () => {
+				viewFragment.appendChildren( parse( '<p>first<br></br>second<br></br>third</p>' ) );
+
+				expect( dataProcessor.toData( viewFragment ) ).to.equal( 'first\nsecond\nthird' );
+			} );
+
+			it( 'should process multi line paragraph with header after it', () => {
+				viewFragment.appendChildren( parse( '<p>single line</p><h1 id="header">header</h1>' ) );
+
+				expect( dataProcessor.toData( viewFragment ) ).to.equal( 'single line\n\n# header' );
+			} );
+
+			it( 'should process multi line paragraph with blockquote after it', () => {
+				viewFragment.appendChildren( parse( '<p>single line</p><blockquote><p>quote</p></blockquote>' ) );
+
+				expect( dataProcessor.toData( viewFragment ) ).to.equal(
+					'single line\n\n' +
+					'> quote'
+				);
+			} );
+
+			it( 'should process paragraph with list after', () => {
+				viewFragment.appendChildren( parse( '<p>single line</p><ul><li>item</li></ul>' ) );
+
+				expect( dataProcessor.toData( viewFragment ) ).to.equal(
+					'single line\n\n' +
+					'*   item'
+				);
+			} );
+
+			it( 'should process paragraph with div after', () => {
+				viewFragment.appendChildren( parse( '<p>single line</p><div>div element</div>' ) );
+
+				expect( dataProcessor.toData( viewFragment ) ).to.equal(
+					'single line\n\n' +
+					'<div>div element</div>'
+				);
+			} );
+		} );
 	} );
 } );

+ 11 - 4
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/strong_and_emphasis.js

@@ -4,6 +4,7 @@
  */
 
 import MarkdownDataProcessor from '/ckeditor5/markdown-gfm/gfmdataprocessor.js';
+import DocumentFragment from '/ckeditor5/engine/view/documentfragment.js';
 import { stringify, parse } from '/tests/engine/_utils/view.js';
 
 describe( 'GFMDataProcessor', () => {
@@ -71,26 +72,32 @@ describe( 'GFMDataProcessor', () => {
 		} );
 
 		describe( 'toData', () => {
+			let viewFragment;
+
+			beforeEach( () => {
+				viewFragment = new DocumentFragment();
+			} );
+
 			it( 'should process strong', () => {
-				const viewFragment = parse( '<p><strong>strong</strong> and <strong>this too</strong></p>' );
+				viewFragment.appendChildren( parse( '<p><strong>strong</strong> and <strong>this too</strong></p>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '**strong** and **this too**' );
 			} );
 
 			it( 'should process emphasis', () => {
-				const viewFragment = parse( '<p><em>emphasis</em> and <em>this too</em></p>' );
+				viewFragment.appendChildren( parse( '<p><em>emphasis</em> and <em>this too</em></p>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '_emphasis_ and _this too_' );
 			} );
 
 			it( 'should process strong and emphasis together #1', () => {
-				const viewFragment = parse( '<p><strong><em>This is strong and em.</em></strong></p>' );
+				viewFragment.appendChildren( parse( '<p><strong><em>This is strong and em.</em></strong></p>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '**_This is strong and em._**' );
 			} );
 
 			it( 'should process strong and emphasis together #2', () => {
-				const viewFragment = parse( '<p><em><strong>This is strong and em.</strong></em></p>' );
+				viewFragment.appendChildren( parse( '<p><em><strong>This is strong and em.</strong></em></p>' ) );
 
 				expect( dataProcessor.toData( viewFragment ) ).to.equal( '_**This is strong and em.**_' );
 			} );

+ 106 - 2
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/tables.js

@@ -4,7 +4,8 @@
  */
 
 import MarkdownDataProcessor from '/ckeditor5/markdown-gfm/gfmdataprocessor.js';
-import { stringify } from '/tests/engine/_utils/view.js';
+import DocumentFragment from '/ckeditor5/engine/view/documentfragment.js';
+import { stringify, parse } from '/tests/engine/_utils/view.js';
 
 describe( 'GFMDataProcessor', () => {
 	let dataProcessor;
@@ -18,7 +19,7 @@ describe( 'GFMDataProcessor', () => {
 			it( 'should process tables', () => {
 				const viewFragment = dataProcessor.toView(
 					'| Heading 1 | Heading 2\n' +
-					'| --------- | ---------\n' +
+					'| --- | ---\n' +
 					'| Cell 1    | Cell 2\n' +
 					'| Cell 3    | Cell 4\n'
 				);
@@ -131,5 +132,108 @@ describe( 'GFMDataProcessor', () => {
 				);
 			} );
 		} );
+
+		describe( 'toData', () => {
+			let viewFragment;
+
+			beforeEach( () => {
+				viewFragment = new DocumentFragment();
+			} );
+
+			it( 'should process tables', () => {
+				viewFragment.appendChildren( parse(
+					'<table>' +
+						'<thead>' +
+							'<tr>' +
+								'<th>Heading 1</th>' +
+								'<th>Heading 2</th>' +
+							'</tr>' +
+						'</thead>' +
+						'<tbody>' +
+							'<tr>' +
+								'<td>Cell 1</td>' +
+								'<td>Cell 2</td>' +
+							'</tr>' +
+							'<tr>' +
+								'<td>Cell 3</td>' +
+								'<td>Cell 4</td>' +
+							'</tr>' +
+						'</tbody>' +
+					'</table>'
+				) );
+
+				expect( dataProcessor.toData( viewFragment ) ).to.equal(
+					'| Heading 1 | Heading 2 |\n' +
+					'| --- | --- |\n' +
+					'| Cell 1 | Cell 2 |\n' +
+					'| Cell 3 | Cell 4 |'
+				);
+			} );
+
+			it( 'should process tables with aligned columns', () => {
+				viewFragment.appendChildren( parse(
+					'<table>' +
+						'<thead>' +
+							'<tr>' +
+								'<th align="center">Header 1</th>' +
+								'<th align="right">Header 2</th>' +
+								'<th align="left">Header 3</th>' +
+								'<th>Header 4</th>' +
+							'</tr>' +
+						'</thead>' +
+						'<tbody>' +
+							'<tr>' +
+								'<td align="center">Cell 1</td>' +
+								'<td align="right">Cell 2</td>' +
+								'<td align="left">Cell 3</td>' +
+								'<td>Cell 4</td>' +
+							'</tr>' +
+							'<tr>' +
+								'<td align="center">Cell 5</td>' +
+								'<td align="right">Cell 6</td>' +
+								'<td align="left">Cell 7</td>' +
+								'<td>Cell 8</td>' +
+							'</tr>' +
+						'</tbody>' +
+					'</table>'
+				) );
+
+				expect( dataProcessor.toData( viewFragment ) ).to.equal(
+					'| Header 1 | Header 2 | Header 3 | Header 4 |\n' +
+					'| :-: | --: | :-- | --- |\n' +
+					'| Cell 1 | Cell 2 | Cell 3 | Cell 4 |\n' +
+					'| Cell 5 | Cell 6 | Cell 7 | Cell 8 |'
+				);
+			} );
+
+			it( 'should process formatting inside cells', () => {
+				viewFragment.appendChildren( parse(
+					'<table>' +
+						'<thead>' +
+							'<tr>' +
+								'<th align="left">Header 1</th>' +
+								'<th align="center">Header 2</th>' +
+								'<th align="right">Header 3</th>' +
+								'<th>Header 4</th>' +
+							'</tr>' +
+						'</thead>' +
+						'<tbody>' +
+							'<tr>' +
+								'<td align="left"><em>Cell 1</em></td>' +
+								'<td align="center"><strong>Cell 2</strong></td>' +
+								'<td align="right"><del>Cell 3</del></td>' +
+								'<td>Cell 4</td>' +
+							'</tr>' +
+						'</tbody>' +
+					'</table>'
+				) );
+
+				expect( dataProcessor.toData( viewFragment ) ).to.equal(
+					'| Header 1 | Header 2 | Header 3 | Header 4 |\n' +
+					'| :-- | :-: | --: | --- |\n' +
+					'| _Cell 1_ | **Cell 2** | ~~Cell 3~~ | Cell 4 |'
+				);
+			} );
+		} );
 	} );
 } );