debian-mirror-gitlab/spec/frontend/lib/gfm/index_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-06-21 17:19:12 +05:30
import { render } from '~/lib/gfm';
describe('gfm', () => {
describe('render', () => {
it('processes Commonmark and provides an ast to the renderer function', async () => {
let result;
await render({
markdown: 'This is text',
renderer: (tree) => {
result = tree;
},
});
expect(result.type).toBe('root');
});
it('transforms raw HTML into individual nodes in the AST', async () => {
let result;
await render({
markdown: '<strong>This is bold text</strong>',
renderer: (tree) => {
result = tree;
},
});
expect(result.children[0].children[0]).toMatchObject({
type: 'element',
tagName: 'strong',
properties: {},
});
});
it('returns the result of executing the renderer function', async () => {
2022-07-16 23:28:13 +05:30
const rendered = { value: 'rendered tree' };
2022-06-21 17:19:12 +05:30
const result = await render({
markdown: '<strong>This is bold text</strong>',
renderer: () => {
2022-07-16 23:28:13 +05:30
return rendered;
2022-06-21 17:19:12 +05:30
},
});
2022-07-16 23:28:13 +05:30
expect(result).toEqual(rendered);
2022-06-21 17:19:12 +05:30
});
});
});