import * as React from 'react'; import { mount } from 'enzyme'; import Markdown from './'; describe('Markdown', () => { let originalGlobalSelf; // TODO: remove this ugly hack, once Markdown is not used for e2e beforeAll(() => { originalGlobalSelf = global.self; Object.defineProperty(global, 'self', { set: i => i, }); global.self = null; }); afterAll(() => { global.self = originalGlobalSelf; }); it('should render markdown source with appropriate html', () => { const source = `# Heading paragraph \`\`\`js 'code'; \`\`\``; const html = mount().html(); expect(html).toContain('

Heading

'); expect(html).toContain('

paragraph

'); expect(html).toContain(''); expect(html).toContain("'code'"); }); it('should trim source before passing it to Remarkable', () => { const source = ` 123 `; const html = mount().html(); expect(html).toContain('

123

'); }); });