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 Oct 23, 2024
1 parent 3964d1f commit e995344
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)

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<p>!&quot;#$%&amp;'()*+,-./:;&lt;=&gt;?@[\\]^_`{|}~</p>" Received: "<p>!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~</p>" at /home/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, bun)

error: expect(received).toEqual(expected)

</p>" </p>" at /home/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<p>*not emphasized*\n&lt;br/&gt; not a tag\n[not a link](/foo)\n`not code`\n1. not a list\n* not a list\n# not a heading\n[foo]: /url &quot;not a reference&quot;\n&amp;ouml; not a character entity</p>" Received: "<p>*not emphasized* <br/> not a tag [not a link](/foo) `not code` 1\\. not a list * not a list # not a heading [foo]: /url <q>not a reference</q> &ouml; not a character entity</p>" at /home/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<p>foo<br />\nbar</p>" Received: "<p>foo bar</p>" at /home/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<p><code>\\[\\`</code></p>" Received: "<p><code>` \\[\\</code> ``</p>" at /home/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<pre><code>\\[\\]\n</code></pre>" Received: "" at /home/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<pre><code>\\[\\]\n</code></pre>" Received: "<p><s>~</s> [] <s>~</s></p>" at /home/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<p><a href=\"https://example.com?find=%5C*\">https://example.com?find=\\*</a></p>" Received: "" at /home/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<a href=\"/bar\\/)\">" Received: "" at /home/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<p><a href=\"/bar*\" title=\"ti*tle\">foo</a></p>" Received: "<p><a title=\"ti\\*tle\" href=\"/bar\\*\">foo</a></p>" at /home/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (macos-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<p>!&quot;#$%&amp;'()*+,-./:;&lt;=&gt;?@[\\]^_`{|}~</p>" Received: "<p>!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~</p>" at /Users/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (macos-latest, bun)

error: expect(received).toEqual(expected)

</p>" </p>" at /Users/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (macos-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<p>*not emphasized*\n&lt;br/&gt; not a tag\n[not a link](/foo)\n`not code`\n1. not a list\n* not a list\n# not a heading\n[foo]: /url &quot;not a reference&quot;\n&amp;ouml; not a character entity</p>" Received: "<p>*not emphasized* <br/> not a tag [not a link](/foo) `not code` 1\\. not a list * not a list # not a heading [foo]: /url <q>not a reference</q> &ouml; not a character entity</p>" at /Users/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (macos-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<p>foo<br />\nbar</p>" Received: "<p>foo bar</p>" at /Users/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (macos-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<p><code>\\[\\`</code></p>" Received: "<p><code>` \\[\\</code> ``</p>" at /Users/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (macos-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<pre><code>\\[\\]\n</code></pre>" Received: "" at /Users/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (macos-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<pre><code>\\[\\]\n</code></pre>" Received: "<p><s>~</s> [] <s>~</s></p>" at /Users/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (macos-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<p><a href=\"https://example.com?find=%5C*\">https://example.com?find=\\*</a></p>" Received: "" at /Users/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (macos-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<a href=\"/bar\\/)\">" Received: "" at /Users/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44

Check failure on line 18 in packages/nuemark/test/cmark.test.js

View workflow job for this annotation

GitHub Actions / test (macos-latest, bun)

error: expect(received).toEqual(expected)

Expected: "<p><a href=\"/bar*\" title=\"ti*tle\">foo</a></p>" Received: "<p><a title=\"ti\\*tle\" href=\"/bar\\*\">foo</a></p>" at /Users/runner/work/nue/nue/packages/nuemark/test/cmark.test.js:18:44
})
}

0 comments on commit e995344

Please sign in to comment.