Welcome to mirror list, hosted at ThFree Co, Russian Federation.

markdown_spec.js « output « cells « notebook « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e3490ed3beaffbe1aae09f66a19dada41bbcff65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { mount } from '@vue/test-utils';
import MarkdownOutput from '~/notebook/cells/output/markdown.vue';
import Prompt from '~/notebook/cells/prompt.vue';
import Markdown from '~/notebook/cells/markdown.vue';
import { relativeRawPath, markdownCellContent } from '../../mock_data';

describe('markdown output cell', () => {
  let wrapper;

  const createComponent = ({ count = 0, index = 0 } = {}) => {
    wrapper = mount(MarkdownOutput, {
      provide: { relativeRawPath },
      propsData: {
        rawCode: markdownCellContent,
        count,
        index,
      },
    });
  };

  beforeEach(() => {
    createComponent();
  });

  const findPrompt = () => wrapper.findComponent(Prompt);
  const findMarkdown = () => wrapper.findComponent(Markdown);

  it.each`
    index | count | showOutput
    ${0}  | ${1}  | ${true}
    ${1}  | ${2}  | ${false}
    ${2}  | ${3}  | ${false}
  `('renders a prompt', ({ index, count, showOutput }) => {
    createComponent({ count, index });
    expect(findPrompt().props()).toMatchObject({ count, showOutput, type: 'Out' });
  });

  it('renders a Markdown component', () => {
    expect(findMarkdown().props()).toMatchObject({
      cell: { source: markdownCellContent },
      hidePrompt: true,
    });
  });
});