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

frontmatter_spec.js « wrappers « components « content_editor « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: de8f8efd260b3177024da5b3b76dc72974f48739 (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
import { NodeViewWrapper, NodeViewContent } from '@tiptap/vue-2';
import { shallowMount } from '@vue/test-utils';
import FrontmatterWrapper from '~/content_editor/components/wrappers/frontmatter.vue';

describe('content/components/wrappers/frontmatter', () => {
  let wrapper;

  const createWrapper = async (nodeAttrs = { language: 'yaml' }) => {
    wrapper = shallowMount(FrontmatterWrapper, {
      propsData: {
        node: {
          attrs: nodeAttrs,
        },
      },
    });
  };

  afterEach(() => {
    wrapper.destroy();
  });

  it('renders a node-view-wrapper as a pre element', () => {
    createWrapper();

    expect(wrapper.findComponent(NodeViewWrapper).props().as).toBe('pre');
    expect(wrapper.findComponent(NodeViewWrapper).classes()).toContain('gl-relative');
  });

  it('renders a node-view-content as a code element', () => {
    createWrapper();

    expect(wrapper.findComponent(NodeViewContent).props().as).toBe('code');
  });

  it('renders label indicating that code block is frontmatter', () => {
    createWrapper();

    const label = wrapper.find('[data-testid="frontmatter-label"]');

    expect(label.text()).toEqual('frontmatter:yaml');
    expect(label.classes()).toEqual(['gl-absolute', 'gl-top-0', 'gl-right-3']);
  });
});