From 0d89e0f5f1e5870c9074ddd0c62f54cef55162ef Mon Sep 17 00:00:00 2001 From: nobkd <44443899+nobkd@users.noreply.github.com> Date: Thu, 14 Nov 2024 19:22:11 +0100 Subject: [PATCH] test: cmark-spec --- bun.lockb | Bin 12080 -> 12440 bytes packages/nuemark/package.json | 3 +++ packages/nuemark/test/cmark.test.js | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 packages/nuemark/test/cmark.test.js diff --git a/bun.lockb b/bun.lockb index 846fd194b284f3fdc77a3cacde7b936fd9dc0b6c..26557fbfac6ec95923471fcd13ad78e4a6c5b334 100755 GIT binary patch delta 2009 zcmds2drX^E6uXw43UijqcBCyr~%Ek z>_K;?nND4%iK2^&X`*vH;{I90M~n=OQ;Fix7}U&#%%Smh&ev9wnZ>{S$CI4zch32p z@7{C!oqIa&J?0yAvh|3Q!;4!>lm$!@ zbEv^0ILx63tWDh*NMI~D$r&>so~*bOO{R+%ex<~$h)7Q)grOQa>g3S;?Kebc@hSx^PoBHRe0ioL2CWGazSflc8NEb*`{zEahIM=8T#90gU+pjUyO92VpregQ;f zmCB@KYy-vwSP(pNA9}ZeNl~tP4Xsj)bFe8r{2LHe!$WumhGB-MXDU?uF_{jPzqfKaLt?iO^E3FE0sT zs3!Pf_9{~Y2XW=tkQbe^caEJoerA;)fwNYTpM=lxISE&+9sCru*ot{Kglrw9u{j=i z^Ux!eg00fdy*IlGv1}Hb;I-b4?}ne3y(@5Uk*k;(eLRfY4Y1L^mLG

|(~hrIubl z;rfiUiyl%kP3ogr^g$Rqng#1JtJQBu-FYXBWZGdYvo*1;$M5gy_WSyFIs?7!ZQ=N= zB{^g}j5*g3Zm0X2h%@pP!$0O85mW|OWTP@zaN1!!->MEqBh_yBEPo>xz~*%0bBnW? gEAa0kPu=T|ymHJ9`|=&2bmgeOiiVU0u+H`KUoygal>h($ delta 1763 zcmcgtU2KzO6n@{Y`@Z#O6S}o)>(=h;56hOd-@5Tr8)j>WiNY45(K)Kw=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.json index d75aa82e..b95f4cc3 100644 --- a/packages/nuemark/package.json +++ b/packages/nuemark/package.json @@ -18,6 +18,9 @@ "js-yaml": "^4.1.0", "nue-glow": "*" }, + "devDependencies": { + "commonmark-spec": "^0.31.2" + }, "jest": { "setupFilesAfterEnv": [ "jest-extended/all", diff --git a/packages/nuemark/test/cmark.test.js b/packages/nuemark/test/cmark.test.js new file mode 100644 index 00000000..fb245b2a --- /dev/null +++ b/packages/nuemark/test/cmark.test.js @@ -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) + }) +}