/* global expect*/ const mdastToHTML = require('./mdast-to-html'); const mdastMixedNodes = require('./__fixtures__/mdast-mixed-nodes.json'); const mdastWithEmNode = require('./__fixtures__/mdast-with-em.json'); const singleNode = require('./__fixtures__/non-id-node.json'); const leadingInlineHTMLNode = require('./__fixtures__/leading-html-node.json'); describe('mdast-to-html', () => { it('should return a string', () => { expect.assertions(1); const actual = mdastToHTML(mdastMixedNodes); expect(typeof actual).toBe('string'); }); it('throws if it is not passed an array', () => { expect.assertions(1); expect(() => mdastToHTML(singleNode)).toThrow( 'mdastToHTML expects an array argument' ); }); it('should convert markdown nodes into html', () => { const actual = mdastToHTML([mdastWithEmNode]); expect(actual).toBe( '

Just some emphasis and a bit of bold

' ); }); it('should not escape html', () => { const actual = mdastToHTML(mdastMixedNodes); expect(actual).toBe(`

Paragraph 1

Third hint with code and inline code

`); }); it('should put inline html inside the enclosing paragraph', () => { const actual = mdastToHTML([leadingInlineHTMLNode]); expect(actual).toBe( '

code in code tags emphasis followed' + ' by

some nested html

' ); }); });