From 749486ba3c9ae91029b562d464c2dbb1c3953338 Mon Sep 17 00:00:00 2001 From: Steven Date: Sat, 15 Oct 2022 21:57:56 +0800 Subject: [PATCH] chore: update marked tests --- web/src/labs/marked/marked.test.ts | 75 +++++++++++++++--------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/web/src/labs/marked/marked.test.ts b/web/src/labs/marked/marked.test.ts index cf7f9afb..1dd0fda5 100644 --- a/web/src/labs/marked/marked.test.ts +++ b/web/src/labs/marked/marked.test.ts @@ -3,44 +3,6 @@ import { unescape } from "lodash-es"; import { marked } from "."; describe("test marked parser", () => { - test("test markdown table", () => { - const tests = [ - { - markdown: `text above the table -| a | b | c | -|---|---|---| -| 1 | 2 | 3 | -| 4 | 5 | 6 | -text below the table -`, - want: `

text above the table

- - - - - - - - - -
abc
123
456
-

text below the table

-`, - }, - { - markdown: `| a | b | c | -| 1 | 2 | 3 | -| 4 | 5 | 6 |`, - want: `

| a | b | c |

-

| 1 | 2 | 3 |

-

| 4 | 5 | 6 |

`, - }, - ]; - for (const t of tests) { - expect(unescape(marked(t.markdown))).toBe(t.want); - } - }); - test("parse code block", () => { const tests = [ { @@ -159,4 +121,41 @@ console.log("hello world!") expect(unescape(marked(t.markdown))).toBe(t.want); } }); + test("parse table", () => { + const tests = [ + { + markdown: `text above the table +| a | b | c | +|---|---|---| +| 1 | 2 | 3 | +| 4 | 5 | 6 | +text below the table +`, + want: `

text above the table

+ + + + + + + + + +
abc
123
456
+

text below the table

+`, + }, + { + markdown: `| a | b | c | +| 1 | 2 | 3 | +| 4 | 5 | 6 |`, + want: `

| a | b | c |

+

| 1 | 2 | 3 |

+

| 4 | 5 | 6 |

`, + }, + ]; + for (const t of tests) { + expect(unescape(marked(t.markdown))).toBe(t.want); + } + }); });