| 
									
										
										
										
											2021-08-02 15:39:40 +02:00
										 |  |  | const leadingInlineHTMLNode = require('./__fixtures__/leading-html-node.json'); | 
					
						
							| 
									
										
										
										
											2020-11-27 19:02:05 +01:00
										 |  |  | const mdastMixedNodes = require('./__fixtures__/mdast-mixed-nodes.json'); | 
					
						
							|  |  |  | const mdastWithEmNode = require('./__fixtures__/mdast-with-em.json'); | 
					
						
							|  |  |  | const singleNode = require('./__fixtures__/non-id-node.json'); | 
					
						
							| 
									
										
										
										
											2021-08-02 15:39:40 +02:00
										 |  |  | const mdastToHTML = require('./mdast-to-html'); | 
					
						
							| 
									
										
										
										
											2020-11-27 19:02:05 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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( | 
					
						
							|  |  |  |       '<p>Just some <em>emphasis</em> and a bit of <strong>bold</strong></p>' | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('should not escape html', () => { | 
					
						
							|  |  |  |     const actual = mdastToHTML(mdastMixedNodes); | 
					
						
							|  |  |  |     expect(actual).toBe(`<p>Paragraph 1</p>
 | 
					
						
							|  |  |  | <p>Third <em>hint</em> with <code>code</code> and <code>inline code</code></p>`); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('should put inline html inside the enclosing paragraph', () => { | 
					
						
							|  |  |  |     const actual = mdastToHTML([leadingInlineHTMLNode]); | 
					
						
							|  |  |  |     expect(actual).toBe( | 
					
						
							|  |  |  |       '<p><code> code in </code> code tags <em>emphasis</em> followed' + | 
					
						
							|  |  |  |         ' by <div><span>some nested html </span></div></p>' | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | }); |