diff options
author | Lauri Ojansivu <x@xet7.org> | 2019-04-20 15:18:33 +0300 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2019-04-20 15:18:33 +0300 |
commit | 73e265d8fd050ae3daa67472b4465a5c49d68910 (patch) | |
tree | 677b233934a43d8f873e24c794ce289d85e3a9b7 /packages/markdown/marked/test/specs/run-spec.js | |
parent | 6117097a93bfb11c8bd4c87a23c44a50e22ceb87 (diff) | |
download | wekan-73e265d8fd050ae3daa67472b4465a5c49d68910.tar.gz wekan-73e265d8fd050ae3daa67472b4465a5c49d68910.tar.bz2 wekan-73e265d8fd050ae3daa67472b4465a5c49d68910.zip |
Include to Wekan packages directory contents, so that meteor command would build all directly.
This also simplifies build scripts.
Thanks to xet7 !
Diffstat (limited to 'packages/markdown/marked/test/specs/run-spec.js')
-rw-r--r-- | packages/markdown/marked/test/specs/run-spec.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/packages/markdown/marked/test/specs/run-spec.js b/packages/markdown/marked/test/specs/run-spec.js new file mode 100644 index 00000000..3af0aa45 --- /dev/null +++ b/packages/markdown/marked/test/specs/run-spec.js @@ -0,0 +1,52 @@ +function runSpecs(title, file, options) { + const json = require(file); + let longestName = 0; + let maxSpecs = 0; + const specs = json.reduce((obj, spec) => { + if (!obj[spec.section]) { + longestName = Math.max(spec.section.length, longestName); + obj[spec.section] = { + specs: [], + pass: 0, + total: 0 + }; + } + obj[spec.section].total++; + maxSpecs = Math.max(obj[spec.section].total, maxSpecs); + if (!spec.shouldFail) { + obj[spec.section].pass++; + } + obj[spec.section].specs.push(spec); + return obj; + }, {}); + + describe(title, () => { + const maxSpecsLen = ('' + maxSpecs).length; + const spaces = maxSpecsLen * 2 + longestName + 11; + console.log('-'.padEnd(spaces + 4, '-')); + console.log(`| ${title.padStart(Math.ceil((spaces + title.length) / 2)).padEnd(spaces)} |`); + console.log(`| ${' '.padEnd(spaces)} |`); + Object.keys(specs).forEach(section => { + console.log(`| ${section.padEnd(longestName)} ${('' + specs[section].pass).padStart(maxSpecsLen)} of ${('' + specs[section].total).padStart(maxSpecsLen)} ${(100 * specs[section].pass / specs[section].total).toFixed().padStart(4)}% |`); + describe(section, () => { + specs[section].specs.forEach((spec) => { + if (options) { + spec.options = Object.assign({}, options, (spec.options || {})); + } + (spec.only ? fit : it)('should ' + (spec.shouldFail ? 'fail' : 'pass') + ' example ' + spec.example, () => { + if (spec.shouldFail) { + expect(spec).not.toRender(spec.html); + } else { + expect(spec).toRender(spec.html); + } + }); + }); + }); + }); + console.log('-'.padEnd(spaces + 4, '-')); + console.log(); + }); +}; + +runSpecs('GFM 0.29', './gfm/gfm.0.29.json', {gfm: true}); +runSpecs('CommonMark 0.29', './commonmark/commonmark.0.29.json', {headerIds: false}); |