summaryrefslogtreecommitdiff
path: root/spec/frontend/content_editor/markdown_processing_spec.js
blob: 71565768558c6691de6e7f9844d5c3ed4e2243d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { createContentEditor } from '~/content_editor';
import { loadMarkdownApiExamples, loadMarkdownApiResult } from './markdown_processing_examples';

jest.mock('~/emoji');

describe('markdown processing', () => {
  // Ensure we generate same markdown that was provided to Markdown API.
  it.each(loadMarkdownApiExamples())(
    'correctly handles %s (context: %s)',
    async (name, context, markdown) => {
      const testName = context ? `${context}_${name}` : name;
      const contentEditor = createContentEditor({
        renderMarkdown: () => loadMarkdownApiResult(testName),
      });
      await contentEditor.setSerializedContent(markdown);

      expect(contentEditor.getSerializedContent()).toBe(markdown);
    },
  );
});