Skip to content

Commit

Permalink
Merge pull request #1219 from 8fold/code-span-email
Browse files Browse the repository at this point in the history
Test for #1218 & "marked" spec
  • Loading branch information
styfle authored Apr 17, 2018
2 parents 6d2568b + bbca016 commit 2f3af91
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"test:specs": "npm test -- test/specs/**/*-spec.js",
"test:cm": "npm test -- test/specs/commonmark/**/*-spec.js",
"test:gfm": "npm test -- test/specs/gfm/**/*-spec.js",
"test:marked": "npm test -- test/specs/marked/**/*-spec.js",
"test:old": "node test",
"test:lint": "eslint bin/marked .",
"test:redos": "eslint --plugin vuln-regex-detector --rule '\"vuln-regex-detector/no-vuln-regex\": 2' lib/marked.js",
Expand Down
48 changes: 48 additions & 0 deletions test/specs/marked/marked-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Marked does not have a custom markdown specification. However, there are times
* when we come across use cases that are not defined in a given specification.
* Therefore, we will put use cases together to illustrate those instances to
* consumers of marked.
*
*/
var marked = require('../../../lib/marked.js');
var markedSpec = require('./marked.json');
var HtmlDiffer = require('html-differ').HtmlDiffer,
htmlDiffer = new HtmlDiffer();
var since = require('jasmine2-custom-message');

var Messenger = function() {}

Messenger.prototype.message = function(spec, expected, actual) {
return 'CommonMark (' + spec.section + '):\n' + spec.markdown + '\n------\n\nExpected:\n' + expected + '\n------\n\nMarked:\n' + actual;
}

Messenger.prototype.test = function(spec, section, ignore) {
if (spec.section === section) {
var shouldFail = ~ignore.indexOf(spec.example);
it('should ' + (shouldFail ? 'fail' : 'pass') + ' example ' + spec.example, function() {
var expected = spec.html;
var actual = marked(spec.markdown, { headerIds: false, xhtml: true });
since(messenger.message(spec, expected, actual)).expect(
htmlDiffer.isEqual(expected, actual)
).toEqual(!shouldFail);
});
}
}

var messenger = new Messenger();

describe('Marked Code spans', function() {
var section = 'Code spans';

// var shouldPassButFails = [];
var shouldPassButFails = [1];

var willNotBeAttemptedByCoreTeam = [];

var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);

markedSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});
8 changes: 8 additions & 0 deletions test/specs/marked/marked.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"section": "Code spans",
"markdown": "`[email protected]`",
"html": "<p><code>[email protected]</code></p>\n",
"example": 1
}
]

0 comments on commit 2f3af91

Please sign in to comment.