forked from markedjs/marked
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test for markedjs#1218 & "marked" spec
- Loading branch information
Josh Bruce
committed
Apr 15, 2018
1 parent
e3a00f8
commit f85a8cc
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* 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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
] |