Skip to content

Commit

Permalink
add run-spec
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Mar 12, 2019
1 parent e540b6a commit 5f2f087
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/specs/run-spec.js
Original file line number Diff line number Diff line change
@@ -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});

0 comments on commit 5f2f087

Please sign in to comment.