chore(widget-markdown): add failing commonmark spec (#2263)

This commit is contained in:
Shawn Erquhart 2019-05-20 09:48:02 -04:00 committed by GitHub
parent 8e1556f908
commit dc1ba6d41b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5024 additions and 0 deletions

View File

@ -0,0 +1,30 @@
import { flow, trim } from 'lodash';
import commonmarkSpec from './__fixtures__/commonmark.json';
import { markdownToSlate, slateToMarkdown, markdownToHtml } from '../index.js';
/**
* Map the commonmark spec data into an array of arrays for use in Jest's
* `test.each`.
*/
const spec = commonmarkSpec.map(({ markdown, html }) => [markdown, html]);
/**
* Each test receives input markdown and output html as expected for Commonmark
* compliance. To test all of our handling in one go, we serialize the markdown
* into our Slate AST, then back to raw markdown, and finally to HTML.
*/
const process = flow([markdownToSlate, slateToMarkdown, markdownToHtml]);
/**
* Passing this test suite requires 100% Commonmark compliance. There are 624
* tests, of which we're passing about 300 as of introduction of this suite. To
* work on improving Commonmark support, remove `.skip` from this `describe`
* and run the test suite locally.
*/
describe.skip('Commonmark support', () => {
test.each(spec)('%s', (markdown, html) => {
// We're trimming the html from the spec as they all have trailing newlines
// and we never output trailing newlines. This may be a compliance issue.
expect(process(markdown)).toEqual(trim(html));
});
});