summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_shared/issuable/create/components/issuable_create_root_spec.js
blob: 81362edaf375d1138a8b469a2b5b91f50d57a310 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { mount } from '@vue/test-utils';

import IssuableCreateRoot from '~/vue_shared/issuable/create/components/issuable_create_root.vue';
import IssuableForm from '~/vue_shared/issuable/create/components/issuable_form.vue';

const createComponent = ({
  descriptionPreviewPath = '/gitlab-org/gitlab-shell/preview_markdown',
  descriptionHelpPath = '/help/user/markdown',
  labelsFetchPath = '/gitlab-org/gitlab-shell/-/labels.json',
  labelsManagePath = '/gitlab-org/gitlab-shell/-/labels',
} = {}) => {
  return mount(IssuableCreateRoot, {
    propsData: {
      descriptionPreviewPath,
      descriptionHelpPath,
      labelsFetchPath,
      labelsManagePath,
    },
    slots: {
      title: `
        <h1 class="js-create-title">New Issuable</h1>
      `,
      actions: `
        <button class="js-issuable-save">Submit issuable</button>
      `,
    },
  });
};

describe('IssuableCreateRoot', () => {
  let wrapper;

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

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

  describe('template', () => {
    it('renders component container element with class "issuable-create-container"', () => {
      expect(wrapper.classes()).toContain('issuable-create-container');
    });

    it('renders contents for slot "title"', () => {
      const titleEl = wrapper.find('h1.js-create-title');

      expect(titleEl.exists()).toBe(true);
      expect(titleEl.text()).toBe('New Issuable');
    });

    it('renders issuable-form component', () => {
      expect(wrapper.find(IssuableForm).exists()).toBe(true);
    });

    it('renders contents for slot "actions" within issuable-form component', () => {
      const buttonEl = wrapper.find(IssuableForm).find('button.js-issuable-save');

      expect(buttonEl.exists()).toBe(true);
      expect(buttonEl.text()).toBe('Submit issuable');
    });
  });
});