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

description_template_spec.js « fields « components « issue_show « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9ebab31f1ad91e7c065fc384d4342dc0c8f9b5ca (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 Vue from 'vue';
import descriptionTemplate from '~/issue_show/components/fields/description_template.vue';

describe('Issue description template component', () => {
  let vm;
  let formState;

  beforeEach(() => {
    const Component = Vue.extend(descriptionTemplate);
    formState = {
      description: 'test',
    };

    vm = new Component({
      propsData: {
        formState,
        issuableTemplates: [{ name: 'test' }],
        projectPath: '/',
        projectNamespace: '/',
      },
    }).$mount();
  });

  it('renders templates as JSON array in data attribute', () => {
    expect(vm.$el.querySelector('.js-issuable-selector').getAttribute('data-data')).toBe(
      '[{"name":"test"}]',
    );
  });

  it('updates formState when changing template', () => {
    vm.issuableTemplate.editor.setValue('test new template');

    expect(formState.description).toBe('test new template');
  });

  it('returns formState description with editor getValue', () => {
    formState.description = 'testing new template';

    expect(vm.issuableTemplate.editor.getValue()).toBe('testing new template');
  });
});