Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: cmark spec tests #390

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/&gt; 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>`` [` ``</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>~~~ [] ~~~</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/&gt; 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>`` [` ``</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>~~~ [] ~~~</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
})
}
Loading