diff --git a/__tests__/addHeadingIds.integration.test.js b/__tests__/addHeadingIds.integration.test.js deleted file mode 100644 index 486ae4a..0000000 --- a/__tests__/addHeadingIds.integration.test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { processMarkdown } from '../dist/index.cjs'; - -describe('addHeadingIds with actual Markdown', () => { - it('should add IDs to headings in Markdown content', async () => { - const markdown = `# First Heading\n## Second Heading`; - const options = { addHeadingIds: true }; - - const result = await processMarkdown(markdown, options); - const htmlOutput = result.contentHtml; - - expect(htmlOutput).toContain('

First Heading

'); - expect(htmlOutput).toContain('

Second Heading

'); - }); -}); diff --git a/__tests__/processMarkdown.frontmatter.test.js b/__tests__/processMarkdown.frontmatter.test.js new file mode 100644 index 0000000..793946d --- /dev/null +++ b/__tests__/processMarkdown.frontmatter.test.js @@ -0,0 +1,25 @@ +import { processMarkdown } from '../dist/index.cjs'; + +describe('front matter processing', () => { + it('should extract various data types in front matter', async () => { + const markdown = `--- +title: "Title" +number: 123 +array: [1, 2, 3] +object: { key: 'value' } +--- +Content`; + const result = await processMarkdown(markdown); + expect(result.frontMatter).toEqual({ title: "Title", number: 123, array: [1, 2, 3], object: { key: 'value' } }); + }); + + it('should correctly extract front matter', async () => { + const markdown = `--- +title: "Test Title" +--- +Content goes here.`; + const result = await processMarkdown(markdown); + expect(result.frontMatter).toEqual({ title: "Test Title" }); + expect(result.contentHtml).toContain('

Content goes here.

'); + }); +}) \ No newline at end of file diff --git a/__tests__/processMarkdown.gfm.test.js b/__tests__/processMarkdown.gfm.test.js new file mode 100644 index 0000000..3b84d5e --- /dev/null +++ b/__tests__/processMarkdown.gfm.test.js @@ -0,0 +1,18 @@ +import { processMarkdown } from '../dist/index.cjs'; + +describe('github flavoured markdown plugin (gfm)', () => { + it('should convert markdown tables to HTML tables', async () => { + const markdown = `| Header1 | Header2 |\n| ------- | ------- |\n| Cell1 | Cell2 |`; + const result = await processMarkdown(markdown); + expect(result.contentHtml).toContain(''); + expect(result.contentHtml).toContain(''); + expect(result.contentHtml).toContain(''); + }); + + it('should process GFM correctly', async () => { + const markdown = `This is ~~strikethrough~~ and **bold HTML**`; + const result = await processMarkdown(markdown); + expect(result.contentHtml).toContain('strikethrough'); + expect(result.contentHtml).toContain('bold HTML'); + }); +}) \ No newline at end of file diff --git a/__tests__/processMarkdown.sanitization.test.js b/__tests__/processMarkdown.sanitization.test.js new file mode 100644 index 0000000..96d7eb2 --- /dev/null +++ b/__tests__/processMarkdown.sanitization.test.js @@ -0,0 +1,9 @@ +import { processMarkdown } from '../dist/index.cjs'; + +describe('processMarkdown sanitization', () => { + it('should sanitize script tags in HTML', async () => { + const markdown = ``; + const result = await processMarkdown(markdown); + expect(result.contentHtml).not.toContain('
Header1Cell1