Skip to content

Commit e995344

Browse files
committed
test: cmark spec tests
1 parent 3964d1f commit e995344

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

bun.lockb

-1.95 KB
Binary file not shown.

packages/nuemark/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
"js-yaml": "^4.1.0",
1919
"nue-glow": "*"
2020
},
21+
"devDependencies": {
22+
"commonmark-spec": "^0.31.2"
23+
},
2124
"jest": {
2225
"setupFilesAfterEnv": [
2326
"jest-extended/all",

packages/nuemark/test/cmark.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { tests } from 'commonmark-spec'
2+
import { nuemark } from '../index.js'
3+
4+
tests.forEach(v => {
5+
v.markdown = v.markdown.replaceAll('→', '\t').trimEnd()
6+
v.html = v.html.replaceAll('→', '\t').trimEnd()
7+
})
8+
9+
const skipSections = ['Tabs', 'Indented code blocks', 'Raw HTML', 'HTML blocks']
10+
const skipNumbers = []
11+
12+
for (const testCase of tests) {
13+
if (skipSections.includes(testCase.section) ||
14+
skipNumbers.includes(testCase.number)) continue
15+
16+
test(`cmark spec: ${testCase.section}; ${testCase.number}`, () => {
17+
console.log(testCase.number, JSON.stringify(testCase.markdown))
18+
expect(nuemark(testCase.markdown)).toEqual(testCase.html)
19+
})
20+
}

0 commit comments

Comments
 (0)