Skip to content

Commit

Permalink
test: cmark-spec
Browse files Browse the repository at this point in the history
  • Loading branch information
nobkd committed Nov 14, 2024
1 parent 9d031c5 commit d29baee
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 @@ -19,6 +19,9 @@
"marked": "^13.0.3",
"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 d29baee

Please sign in to comment.