From 5f2f0874188ff1079e4c99641a55d391ec1ca043 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sat, 9 Mar 2019 23:37:33 -0600 Subject: [PATCH] add run-spec --- test/specs/run-spec.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/specs/run-spec.js diff --git a/test/specs/run-spec.js b/test/specs/run-spec.js new file mode 100644 index 0000000000..809ae10ce2 --- /dev/null +++ b/test/specs/run-spec.js @@ -0,0 +1,32 @@ +function runSpecs(title, file, options) { + const json = require(file); + const specs = json.reduce((obj, spec) => { + if (!obj[spec.section]) { + obj[spec.section] = []; + } + obj[spec.section].push(spec); + return obj; + }, {}); + + describe(title, function() { + Object.keys(specs).forEach(section => { + describe(section, function() { + specs[section].forEach(function(spec) { + if (options) { + spec.options = Object.assign({}, options, (spec.options || {})); + } + (spec.only ? fit : it)('should ' + (spec.shouldFail ? 'fail' : 'pass') + ' example ' + spec.example, function() { + if (spec.shouldFail) { + expect(spec).not.toRender(spec.html); + } else { + expect(spec).toRender(spec.html); + } + }); + }); + }); + }); + }); +}; + +runSpecs('GFM 0.28', './gfm/gfm.0.28.json', {gfm: true}); +runSpecs('CommonMark 0.28', './commonmark/commonmark.0.28.json', {headerIds: false});