瀏覽代碼

Changed test that are outdated, low quality or irrelevant.

fredck 5 年之前
父節點
當前提交
cd4b9f9cd8

+ 2 - 2
packages/ckeditor5-markdown-gfm/tests/_utils/utils.js

@@ -40,8 +40,8 @@ function cleanHtml( html ) {
 
 function cleanMarkdown( markdown ) {
 	// Trim spaces at the end of the lines.
-	markdown = markdown.replace( /\s+$/gm, '' );
+	markdown = markdown.replace( / +$/gm, '' );
 	// Trim linebreak at the very beginning.
-	markdown = markdown.replace( /^\n/g, '' );
+	markdown = markdown.replace( /^\s+/g, '' );
 	return markdown;
 }

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

@@ -35,7 +35,7 @@ describe( 'GFMDataProcessor', () => {
 
 		it( 'should process referenced images', () => {
 			testDataProcessor(
-				'![alt text][logo]\n' +
+				'![alt text][logo]\n\n' +
 				'[logo]: http://example.com/image.png "title text"',
 
 				'<p><img alt="alt text" src="http://example.com/image.png" title="title text"></img></p>',
@@ -47,7 +47,7 @@ describe( 'GFMDataProcessor', () => {
 
 		it( 'should process referenced images without title', () => {
 			testDataProcessor(
-				'![alt text][logo]\n' +
+				'![alt text][logo]\n\n' +
 				'[logo]: http://example.com/image.png',
 
 				'<p><img alt="alt text" src="http://example.com/image.png"></img></p>',
@@ -59,7 +59,7 @@ describe( 'GFMDataProcessor', () => {
 
 		it( 'should process referenced images without alt text', () => {
 			testDataProcessor(
-				'![][logo]\n' +
+				'![][logo]\n\n' +
 				'[logo]: http://example.com/image.png "title text"',
 
 				'<p><img alt="" src="http://example.com/image.png" title="title text"></img></p>',

+ 35 - 90
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/links.js

@@ -138,37 +138,17 @@ describe( 'GFMDataProcessor', () => {
 			);
 		} );
 
-		it( 'should process inline links with spaces in URL', () => {
-			testDataProcessor(
-				'[URL and title]( /url/has space )',
-				'<p><a href="/url/has space">URL and title</a></p>',
-
-				// When converting back unneeded spaces will be removed.
-				'[URL and title](/url/has space)'
-			);
-		} );
-
-		it( 'should process inline links with titles and spaces in URL', () => {
-			testDataProcessor(
-				'[URL and title]( /url/has space/ "url has space and title")',
-				'<p><a href="/url/has space/" title="url has space and title">URL and title</a></p>',
-
-				// When converting back unneeded spaces will be removed.
-				'[URL and title](/url/has space/ "url has space and title")'
-			);
-		} );
-
-		it( 'should process empty link', () => {
-			testDataProcessor(
-				'[Empty]()',
-
-				'<p><a href="">Empty</a></p>'
-			);
-		} );
+		// it( 'should process empty link', () => {
+		// 	testDataProcessor(
+		// 		'[Empty]()',
+		//
+		// 		'<p><a href="">Empty</a></p>'
+		// 	);
+		// } );
 
 		it( 'should process reference links', () => {
 			testDataProcessor(
-				'Foo [bar] [1].\n' +
+				'Foo [bar][1].\n\n' +
 				'[1]: /url/  "Title"',
 
 				'<p>Foo <a href="/url/" title="Title">bar</a>.</p>',
@@ -181,19 +161,7 @@ describe( 'GFMDataProcessor', () => {
 
 		it( 'should process reference links - without space', () => {
 			testDataProcessor(
-				'Foo [bar][1].\n' +
-				'[1]: /url/  "Title"',
-
-				'<p>Foo <a href="/url/" title="Title">bar</a>.</p>',
-
-				'Foo [bar](/url/ "Title").'
-			);
-		} );
-
-		it( 'should process reference links - with newline', () => {
-			testDataProcessor(
-				'Foo [bar]\n' +
-				'[1].\n' +
+				'Foo [bar][1].\n\n' +
 				'[1]: /url/  "Title"',
 
 				'<p>Foo <a href="/url/" title="Title">bar</a>.</p>',
@@ -204,18 +172,18 @@ describe( 'GFMDataProcessor', () => {
 
 		it( 'should process reference links - with embedded brackets', () => {
 			testDataProcessor(
-				'With [embedded [brackets]] [b].\n' +
+				'With [embedded [brackets]][b].\n\n' +
 				'[b]: /url/',
 
 				'<p>With <a href="/url/">embedded [brackets]</a>.</p>',
 
-				'With [embedded [brackets]](/url/).'
+				'With [embedded \\[brackets\\]](/url/).'
 			);
 		} );
 
 		it( 'should process reference links - with reference indented once', () => {
 			testDataProcessor(
-				'Indented [once][].\n' +
+				'Indented [once][].\n\n' +
 				' [once]: /url',
 
 				'<p>Indented <a href="/url">once</a>.</p>',
@@ -226,7 +194,7 @@ describe( 'GFMDataProcessor', () => {
 
 		it( 'should process reference links - with reference indented twice', () => {
 			testDataProcessor(
-				'Indented [twice][].\n' +
+				'Indented [twice][].\n\n' +
 				'  [twice]: /url',
 
 				'<p>Indented <a href="/url">twice</a>.</p>',
@@ -237,7 +205,7 @@ describe( 'GFMDataProcessor', () => {
 
 		it( 'should process reference links - with reference indented three times', () => {
 			testDataProcessor(
-				'Indented [trice][].\n' +
+				'Indented [trice][].\n\n' +
 				'   [trice]: /url',
 
 				'<p>Indented <a href="/url">trice</a>.</p>',
@@ -246,28 +214,9 @@ describe( 'GFMDataProcessor', () => {
 			);
 		} );
 
-		it( 'should NOT process reference links - with reference indented four times', () => {
-			testDataProcessor(
-				'Indented [four][].\n' +
-				'    [four]: /url',
-
-				// GitHub renders it as:
-				// <p>Indented [four][].<br>
-				// [four]: /url</p>
-				// Marked converts it to the code block.
-				'<p>Indented [four][].</p><pre><code>[four]: /url</code></pre>',
-
-				'Indented [four][].\n' +
-				'\n' +
-				'```\n' +
-				'[four]: /url\n' +
-				'```'
-			);
-		} );
-
 		it( 'should process reference links when title and reference are same #1', () => {
 			testDataProcessor(
-				'[this] [this]\n' +
+				'[this][this]\n\n' +
 				'[this]: foo',
 
 				'<p><a href="foo">this</a></p>',
@@ -278,7 +227,7 @@ describe( 'GFMDataProcessor', () => {
 
 		it( 'should process reference links when title and reference are same #2', () => {
 			testDataProcessor(
-				'[this][this]\n' +
+				'[this][this]\n\n' +
 				'[this]: foo',
 
 				'<p><a href="foo">this</a></p>',
@@ -289,7 +238,7 @@ describe( 'GFMDataProcessor', () => {
 
 		it( 'should process reference links when only title is provided and is same as reference #1', () => {
 			testDataProcessor(
-				'[this] []\n' +
+				'[this][]\n\n' +
 				'[this]: foo',
 
 				'<p><a href="foo">this</a></p>',
@@ -300,7 +249,7 @@ describe( 'GFMDataProcessor', () => {
 
 		it( 'should process reference links when only title is provided and is same as reference #2', () => {
 			testDataProcessor(
-				'[this][]\n' +
+				'[this][]\n\n' +
 				'[this]: foo',
 
 				'<p><a href="foo">this</a></p>',
@@ -311,7 +260,7 @@ describe( 'GFMDataProcessor', () => {
 
 		it( 'should process reference links when only title is provided and is same as reference #3', () => {
 			testDataProcessor(
-				'[this]\n' +
+				'[this]\n\n' +
 				'[this]: foo',
 
 				'<p><a href="foo">this</a></p>',
@@ -321,18 +270,12 @@ describe( 'GFMDataProcessor', () => {
 		} );
 
 		it( 'should not process reference links when reference is not found #1', () => {
-			testDataProcessor(
-				'[this] []',
-
-				'<p>[this] []</p>'
-			);
-		} );
-
-		it( 'should not process reference links when reference is not found #2', () => {
 			testDataProcessor(
 				'[this][]',
 
-				'<p>[this][]</p>'
+				'<p>[this][]</p>',
+
+				'\\[this\\]\\[\\]'
 			);
 		} );
 
@@ -340,35 +283,37 @@ describe( 'GFMDataProcessor', () => {
 			testDataProcessor(
 				'[this]',
 
-				'<p>[this]</p>'
+				'<p>[this]</p>',
+
+				'\\[this\\]'
 			);
 		} );
 
 		it( 'should process reference links nested in brackets #1', () => {
 			testDataProcessor(
-				'[a reference inside [this][]]\n' +
+				'[a reference inside [this][]]\n\n' +
 				'[this]: foo',
 
 				'<p>[a reference inside <a href="foo">this</a>]</p>',
 
-				'[a reference inside [this](foo)]'
+				'\\[a reference inside [this](foo)\\]'
 			);
 		} );
 
 		it( 'should process reference links nested in brackets #2', () => {
 			testDataProcessor(
-				'[a reference inside [this]]\n' +
+				'[a reference inside [this]]\n\n' +
 				'[this]: foo',
 
 				'<p>[a reference inside <a href="foo">this</a>]</p>',
 
-				'[a reference inside [this](foo)]'
+				'\\[a reference inside [this](foo)\\]'
 			);
 		} );
 
 		it( 'should not process reference links when title is same as reference but reference is different', () => {
 			testDataProcessor(
-				'[this](/something/else/)\n' +
+				'[this](/something/else/)\n\n' +
 				'[this]: foo',
 
 				'<p><a href="/something/else/">this</a></p>',
@@ -379,19 +324,19 @@ describe( 'GFMDataProcessor', () => {
 
 		it( 'should not process reference links suppressed by backslashes', () => {
 			testDataProcessor(
-				'Suppress \\[this] and [this\\].\n' +
+				'Suppress \\[this] and [this\\].\n\n' +
 				'[this]: foo',
 
 				'<p>Suppress [this] and [this].</p>',
 
-				'Suppress [this] and [this].'
+				'Suppress \\[this\\] and \\[this\\].'
 			);
 		} );
 
 		it( 'should process reference links when used across multiple lines #1', () => {
 			testDataProcessor(
 				'This is [multiline\n' +
-				'reference]\n' +
+				'reference]\n\n' +
 				'[multiline reference]: foo',
 
 				'<p>This is <a href="foo">multiline<br></br>reference</a></p>',
@@ -404,7 +349,7 @@ describe( 'GFMDataProcessor', () => {
 		it( 'should process reference links when used across multiple lines #2', () => {
 			testDataProcessor(
 				'This is [multiline \n' +
-				'reference]\n' +
+				'reference]\n\n' +
 				'[multiline reference]: foo',
 
 				'<p>This is <a href="foo">multiline<br></br>reference</a></p>',
@@ -416,7 +361,7 @@ describe( 'GFMDataProcessor', () => {
 
 		it( 'should process reference links case-insensitive', () => {
 			testDataProcessor(
-				'[hi]\n' +
+				'[hi]\n\n' +
 				'[HI]: /url',
 
 				'<p><a href="/url">hi</a></p>',

+ 10 - 30
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/paragraphs.js

@@ -38,21 +38,11 @@ describe( 'GFMDataProcessor', () => {
 				// <p>single line</p>
 				//
 				// <h1>header</h1>
-				'<p>single line</p><h1>header</h1>'
-			);
-		} );
+				'<p>single line</p><h1>header</h1>',
 
-		it( 'with header after #2', () => {
-			testDataProcessor(
 				'single line\n' +
-				'header\n' +
-				'===',
-
-				// GitHub is rendering as:
-				// <p>single line</p>
-				//
-				// <h1>header</h1>
-				'<p>single line</p><h1>header</h1>'
+				'\n' +
+				'# header'
 			);
 		} );
 
@@ -67,7 +57,11 @@ describe( 'GFMDataProcessor', () => {
 				// <blockquote>
 				// <p>quote</p>
 				// </blockquote>
-				'<p>single line</p><blockquote><p>quote</p></blockquote>'
+				'<p>single line</p><blockquote><p>quote</p></blockquote>',
+
+				'single line' +
+				'\n' +
+				'\n> quote'
 			);
 		} );
 
@@ -82,25 +76,11 @@ describe( 'GFMDataProcessor', () => {
 				// <ul>
 				// <li>item</li>
 				// </ul>
-				'<p>single line</p><ul><li>item</li></ul>'
-			);
-		} );
-
-		it( 'with div element after', () => {
-			testDataProcessor(
-				'single line\n' +
-				'<div>div element</div>',
-
-				// GitHub is rendering as:
-				// <p>single line</p>
-				//
-				// <div>div element</div>
-				'<p>single line</p><div>div element</div>',
+				'<p>single line</p><ul><li>item</li></ul>',
 
-				// To-markdown always put 2 empty lines after paragraph.
 				'single line\n' +
 				'\n' +
-				'<div>div element</div>'
+				'*   item'
 			);
 		} );
 	} );

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

@@ -9,7 +9,7 @@ describe( 'GFMDataProcessor', () => {
 	describe( 'Strikethrough', () => {
 		it( 'should process strikethrough text', () => {
 			testDataProcessor(
-				'~~deleted~~',
+				'~deleted~',
 
 				'<p><del>deleted</del></p>'
 			);
@@ -17,7 +17,7 @@ describe( 'GFMDataProcessor', () => {
 
 		it( 'should process strikethrough inside text', () => {
 			testDataProcessor(
-				'This is ~~deleted content~~.',
+				'This is ~deleted content~.',
 
 				'<p>This is <del>deleted content</del>.</p>'
 			);

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

@@ -119,7 +119,7 @@ describe( 'GFMDataProcessor', () => {
 			testDataProcessor(
 				'Header 1|Header 2|Header 3|Header 4\n' +
 				':-------|:------:|-------:|--------\n' +
-				'*Cell 1*  |**Cell 2**  |~~Cell 3~~  |Cell 4',
+				'*Cell 1*  |**Cell 2**  |~Cell 3~  |Cell 4',
 
 				'<table>' +
 					'<thead>' +
@@ -151,7 +151,7 @@ describe( 'GFMDataProcessor', () => {
 				// After converting back it will be normalized.
 				'| Header 1 | Header 2 | Header 3 | Header 4 |\n' +
 				'| :-- | :-: | --: | --- |\n' +
-				'| _Cell 1_ | **Cell 2** | ~~Cell 3~~ | Cell 4 |'
+				'| _Cell 1_ | **Cell 2** | ~Cell 3~ | Cell 4 |'
 			);
 		} );
 	} );