Skip to content

Commit

Permalink
test: cmark spec tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nobkd committed Nov 14, 2024
1 parent 6e505b2 commit f6ce9b5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Binary file modified bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions packages/nuemark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"js-yaml": "^4.1.0",
"nue-glow": "*"
},
"devDependencies": {
"commonmark-spec": "^0.31.2"
},
"jest": {
"setupFilesAfterEnv": [
"jest-extended/all",
Expand Down
20 changes: 20 additions & 0 deletions packages/nuemark/test/cmark.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { tests } from 'commonmark-spec'
import { nuemark } from '../index.js'

tests.forEach(v => {
v.markdown = v.markdown.replaceAll('→', '\t').trimEnd()
v.html = v.html.replaceAll('→', '\t').trimEnd()
})

const skipSections = ['Tabs', 'Indented code blocks', 'Raw HTML', 'HTML blocks']
const skipNumbers = []

for (const testCase of tests) {
if (skipSections.includes(testCase.section) ||
skipNumbers.includes(testCase.number)) continue

test(`cmark spec: ${testCase.section}; ${testCase.number}`, () => {
console.log(testCase.number, JSON.stringify(testCase.markdown))
expect(nuemark(testCase.markdown)).toEqual(testCase.html)
})
}

0 comments on commit f6ce9b5

Please sign in to comment.