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: 39d205839f4b5f76a39d8e664d99cc04ff333253 (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
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 createComponent = (props = {}, mountFn = shallowMount) => {
    wrapper = mountFn(TextEditor, {
      propsData: {
        value: mockCiYml,
        ...props,
      },
    });
  };

  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 readony and configured for .yml', () => {
    expect(findEditor().props('editorOptions')).toEqual({ readOnly: true });
    expect(findEditor().props('fileName')).toBe('*.yml');
  });

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

    expect(wrapper.emitted('editor-ready')).toHaveLength(1);
  });
});