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

ide_status_mr_spec.js « components « ide « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0526d4653f8e1c8e4f196881b03fe252878d9e23 (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
import { GlIcon, GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import { TEST_HOST } from 'helpers/test_constants';
import IdeStatusMr from '~/ide/components/ide_status_mr.vue';

const TEST_TEXT = '!9001';
const TEST_URL = `${TEST_HOST}merge-requests/9001`;

describe('ide/components/ide_status_mr', () => {
  let wrapper;

  const createComponent = (props) => {
    wrapper = shallowMount(IdeStatusMr, {
      propsData: props,
    });
  };
  const findIcon = () => wrapper.find(GlIcon);
  const findLink = () => wrapper.find(GlLink);

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

  describe('when mounted', () => {
    beforeEach(() => {
      createComponent({
        text: TEST_TEXT,
        url: TEST_URL,
      });
    });

    it('renders icon', () => {
      const icon = findIcon();

      expect(icon.exists()).toBe(true);
      expect(icon.props()).toEqual(
        expect.objectContaining({
          name: 'merge-request',
        }),
      );
    });

    it('renders link', () => {
      const link = findLink();

      expect(link.exists()).toBe(true);
      expect(link.attributes()).toEqual(
        expect.objectContaining({
          href: TEST_URL,
        }),
      );
      expect(link.text()).toEqual(TEST_TEXT);
    });

    it('renders text', () => {
      expect(wrapper.text()).toBe(`Merge request ${TEST_TEXT}`);
    });
  });
});