wix-storybook-utils
Version:
Utilities for automated component documentation within Storybook
31 lines • 1.26 kB
JavaScript
import * as React from 'react';
import { mount } from 'enzyme';
import Markdown from './';
describe('Markdown', function () {
var originalGlobalSelf;
// TODO: remove this ugly hack, once Markdown is not used for e2e
beforeAll(function () {
originalGlobalSelf = global.self;
Object.defineProperty(global, 'self', {
set: function (i) { return i; },
});
global.self = null;
});
afterAll(function () {
global.self = originalGlobalSelf;
});
it('should render markdown source with appropriate html', function () {
var source = "# Heading\n\nparagraph\n\n```js\n'code';\n```";
var html = mount(React.createElement(Markdown, { source: source })).html();
expect(html).toContain('<h1>Heading</h1>');
expect(html).toContain('<p>paragraph</p>');
expect(html).toContain('<code class="language-js">');
expect(html).toContain("'code'</span>");
});
it('should trim source before passing it to Remarkable', function () {
var source = "\n\n 123\n ";
var html = mount(React.createElement(Markdown, { source: source })).html();
expect(html).toContain('<p>123</p>');
});
});
//# sourceMappingURL=index.test.js.map