From 2c614fec10f0761c177d02282aafc42a890cfe4c Mon Sep 17 00:00:00 2001 From: Reed von Redwitz Date: Thu, 18 Jan 2024 10:22:16 +0100 Subject: [PATCH] chore: add basic md table with dollar sign test --- test/fixtures/basic_md_table.html | 60 +++++++++++++++++++++++++++++++ test/test.ts | 40 ++++++++++++++++++++- 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/basic_md_table.html diff --git a/test/fixtures/basic_md_table.html b/test/fixtures/basic_md_table.html new file mode 100644 index 0000000..d2a3caf --- /dev/null +++ b/test/fixtures/basic_md_table.html @@ -0,0 +1,60 @@ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Fruit NameQuantityUnit Cost per ItemSubtotal
Apple1$1.50$1.50
Pear2$2.00$4.00
Orange3$2.50$7.50
Grape60$0.05$3.00
Total$16.00
+ +
+ + diff --git a/test/test.ts b/test/test.ts index 36913bb..f3ab228 100644 --- a/test/test.ts +++ b/test/test.ts @@ -1,6 +1,6 @@ import { assertEquals } from "https://deno.land/std@0.211.0/assert/assert_equals.ts"; import { DOMParser } from "https://deno.land/x/deno_dom@v0.1.43/deno-dom-wasm.ts"; -import { render, Renderer } from "../mod.ts"; +import { CSS, render, Renderer } from "../mod.ts"; Deno.test("Basic markdown", async () => { const markdown = await Deno.readTextFile("./test/fixtures/basic.md"); @@ -232,3 +232,41 @@ Deno.test( assertEquals(html, expected.trim()); }, ); + +Deno.test("basic md table with dollar signs", () => { + const markdown = `| Fruit Name | Quantity | Unit Cost per Item | Subtotal | + |------------|----------|--------------------|----------| + | Apple | 1 | $1.50 | $1.50 | + | Pear | 2 | $2.00 | $4.00 | + | Orange | 3 | $2.50 | $7.50 | + | Grape | 60 | $0.05 | $3.00 | + | Total | | | $16.00 |`; + + const body = render(markdown); + const html = ` + + + + + + + + +
+ ${body} +
+ + +`; + // uncomment to update the fixture when the css changes + // Deno.writeTextFileSync("./test/fixtures/basic_md_table.html", html); + + const expected = Deno.readTextFileSync("./test/fixtures/basic_md_table.html"); + assertEquals(html, expected); +});