mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 04:51:31 +08:00 
			
		
		
		
	refactor(test): use matrix for testing import/export
This commit is contained in:
		
							parent
							
								
									8c71e6aa90
								
							
						
					
					
						commit
						b278bc8ce4
					
				| @ -7,22 +7,22 @@ describe("Markdown export", () => { | |||||||
|     it("exports correct language tag for known languages", () => { |     it("exports correct language tag for known languages", () => { | ||||||
|         const conversionTable = { |         const conversionTable = { | ||||||
|             "language-text-x-nginx-conf": "nginx", |             "language-text-x-nginx-conf": "nginx", | ||||||
|             "language-x-diff": "diff", |             "language-text-x-diff": "diff", | ||||||
|             "language-application-javascript-env-frontend": "javascript", |             "language-application-javascript-env-frontend": "javascript", | ||||||
|             "language-application-javascript-env-backend": "javascript" |             "language-application-javascript-env-backend": "javascript" | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         for (const [ a, b ] of Object.entries(conversionTable)) { |         for (const [ input, output ] of Object.entries(conversionTable)) { | ||||||
|             const html = trimIndentation`\ |             const html = trimIndentation`\ | ||||||
|                 <p>A diff:</p> |                 <p>A diff:</p> | ||||||
|                 <pre><code class="${a}">Hello |                 <pre><code class="${input}">Hello | ||||||
|                 -world |                 -world | ||||||
|                 +worldy |                 +worldy | ||||||
|                 </code></pre>`;
 |                 </code></pre>`;
 | ||||||
|             const expected = trimIndentation`\ |             const expected = trimIndentation`\ | ||||||
|                 A diff: |                 A diff: | ||||||
| 
 | 
 | ||||||
|                 \`\`\`${b} |                 \`\`\`${output} | ||||||
|                 Hello |                 Hello | ||||||
|                 -world |                 -world | ||||||
|                 +worldy |                 +worldy | ||||||
|  | |||||||
| @ -3,6 +3,35 @@ import { trimIndentation } from "../../../spec/support/utils.js"; | |||||||
| import markdownService from "./markdown.js"; | import markdownService from "./markdown.js"; | ||||||
| 
 | 
 | ||||||
| describe("markdown", () => { | describe("markdown", () => { | ||||||
|  |     it("rewrites language of known language tags", () => { | ||||||
|  |         const conversionTable = { | ||||||
|  |             "nginx": "language-text-x-nginx-conf", | ||||||
|  |             "diff": "language-text-x-diff", | ||||||
|  |             "javascript": "language-application-javascript-env-backend", | ||||||
|  |             "css": "language-text-css" | ||||||
|  |         }; | ||||||
|  | 
 | ||||||
|  |         for (const [ input, output ] of Object.entries(conversionTable)) { | ||||||
|  |             const result = markdownService.renderToHtml(trimIndentation`\ | ||||||
|  |                 \`\`\`${input} | ||||||
|  |                 Hi | ||||||
|  |                 \`\`\` | ||||||
|  |             `, "title");
 | ||||||
|  |             expect(result).toBe(trimIndentation`\ | ||||||
|  |                 <pre><code class="${output}">Hi</code></pre>`);
 | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     it("rewrites language of unknown language tags", () => { | ||||||
|  |         const result = markdownService.renderToHtml(trimIndentation`\ | ||||||
|  |             \`\`\`unknownlanguage
 | ||||||
|  |             Hi | ||||||
|  |             \`\`\` | ||||||
|  |         `, "title");
 | ||||||
|  |         expect(result).toBe(trimIndentation`\ | ||||||
|  |             <pre><code class="language-text-x-trilium-auto">Hi</code></pre>`);
 | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|     it("converts h1 heading", () => { |     it("converts h1 heading", () => { | ||||||
|         const result = markdownService.renderToHtml(trimIndentation`\ |         const result = markdownService.renderToHtml(trimIndentation`\ | ||||||
|             # Hello |             # Hello | ||||||
| @ -18,28 +47,6 @@ describe("markdown", () => { | |||||||
|         `);
 |         `);
 | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     it("rewrites language of known language tags", () => { |  | ||||||
|         const result = markdownService.renderToHtml(trimIndentation`\ |  | ||||||
|             \`\`\`javascript
 |  | ||||||
|             Hi |  | ||||||
|             \`\`\` |  | ||||||
|             \`\`\`css
 |  | ||||||
|             there |  | ||||||
|             \`\`\` |  | ||||||
|         `, "title");
 |  | ||||||
|         expect(result).toBe(trimIndentation`\ |  | ||||||
|             <pre><code class="language-application-javascript-env-backend">Hi</code></pre><pre><code class="language-text-css">there</code></pre>`);
 |  | ||||||
|     }); |  | ||||||
| 
 |  | ||||||
|     it("rewrites language of unknown language tags", () => { |  | ||||||
|         const result = markdownService.renderToHtml(trimIndentation`\ |  | ||||||
|             \`\`\`unknownlanguage
 |  | ||||||
|             Hi |  | ||||||
|             \`\`\` |  | ||||||
|         `, "title");
 |  | ||||||
|         expect(result).toBe(trimIndentation`\ |  | ||||||
|             <pre><code class="language-text-x-trilium-auto">Hi</code></pre>`);
 |  | ||||||
|     }); |  | ||||||
| 
 | 
 | ||||||
|     it("parses duplicate title with escape correctly", () => { |     it("parses duplicate title with escape correctly", () => { | ||||||
|         const result = markdownService.renderToHtml(trimIndentation`\ |         const result = markdownService.renderToHtml(trimIndentation`\ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran