summaryrefslogtreecommitdiff
path: root/spec/frontend/content_editor/markdown_processing_examples.js
blob: 12eed00f3c68abc8675e557c610bce329c98889a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import fs from 'fs';
import path from 'path';
import jsYaml from 'js-yaml';
import { getJSONFixture } from 'helpers/fixtures';

export const loadMarkdownApiResult = (testName) => {
  const fixturePathPrefix = `api/markdown/${testName}.json`;

  return getJSONFixture(fixturePathPrefix);
};

export const loadMarkdownApiExamples = () => {
  const apiMarkdownYamlPath = path.join(__dirname, '..', 'fixtures', 'api_markdown.yml');
  const apiMarkdownYamlText = fs.readFileSync(apiMarkdownYamlPath);
  const apiMarkdownExampleObjects = jsYaml.safeLoad(apiMarkdownYamlText);

  return apiMarkdownExampleObjects.map(({ name, context, markdown }) => [name, context, markdown]);
};