Skip to content

Commit da0cc31

Browse files
Test setup and added a complex unit test (#10)
This PR fixed the unit test setup and added a complex unit test.
2 parents 92aa7fe + 55a40dc commit da0cc31

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

tests/Functions.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,26 @@ describe("convertMarkdownToHtml", () => {
3434
);
3535
expect(() => convertMarkdownToHtml(123)).toThrow("Markdown parse error");
3636
});
37+
38+
it("converts complex markdown with multiple elements", () => {
39+
const md = `
40+
# Title
41+
42+
This is a paragraph with **bold** text and a [link](https://example.com).
43+
44+
- List item 1
45+
- List item 2
46+
47+
> A blockquote
48+
`;
49+
const html = convertMarkdownToHtml(md);
50+
expect(html).toContain("<h1>Title</h1>");
51+
expect(html).toContain(
52+
'<p>This is a paragraph with <strong>bold</strong> text and a <a href="https://example.com">link</a>.</p>',
53+
);
54+
expect(html).toContain(
55+
"<ul>\n<li>List item 1</li>\n<li>List item 2</li>\n</ul>",
56+
);
57+
expect(html).toContain("<blockquote>\n<p>A blockquote</p>\n</blockquote>");
58+
});
3759
});

tests/test.setup.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
import { randomUUID } from "node:crypto"; // Node.js built-in crypto
2-
global.crypto = { randomUUID }; // Mock or polyfill necessary crypto functions
1+
import { randomUUID } from "node:crypto";
2+
3+
if (!globalThis.crypto?.randomUUID) {
4+
Object.defineProperty(globalThis, "crypto", {
5+
value: { randomUUID },
6+
configurable: true,
7+
});
8+
}

0 commit comments

Comments
 (0)