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

text_editor_spec.js « components « pipeline_editor « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 18f71ebc95cc08f86476d3488f2a48e36ab7b44c (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 { shallowMount } from '@vue/test-utils';
import EditorLite from '~/vue_shared/components/editor_lite.vue';
import { mockCiYml } from '../mock_data';

import TextEditor from '~/pipeline_editor/components/text_editor.vue';

describe('~/pipeline_editor/components/text_editor.vue', () => {
  let wrapper;
  const editorReadyListener = jest.fn();

  const createComponent = (attrs = {}, mountFn = shallowMount) => {
    wrapper = mountFn(TextEditor, {
      attrs: {
        value: mockCiYml,
        ...attrs,
      },
      listeners: {
        'editor-ready': editorReadyListener,
      },
    });
  };

  const findEditor = () => wrapper.find(EditorLite);

  it('contains an editor', () => {
    createComponent();

    expect(findEditor().exists()).toBe(true);
  });

  it('editor contains the value provided', () => {
    expect(findEditor().props('value')).toBe(mockCiYml);
  });

  it('editor is configured for .yml', () => {
    expect(findEditor().props('fileName')).toBe('*.yml');
  });

  it('bubbles up events', () => {
    findEditor().vm.$emit('editor-ready');

    expect(editorReadyListener).toHaveBeenCalled();
  });
});