summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_mr_widget/components/states/mr_widget_merging_spec.js
blob: e6b2e9fa176d9d4ea92878c7bcfaab7865f5b8de (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
import { shallowMount } from '@vue/test-utils';
import MrWidgetMerging from '~/vue_merge_request_widget/components/states/mr_widget_merging.vue';

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

  const GlEmoji = { template: '<img />' };
  beforeEach(() => {
    wrapper = shallowMount(MrWidgetMerging, {
      propsData: {
        mr: {
          targetBranchPath: '/branch-path',
          targetBranch: 'branch',
        },
      },
      stubs: {
        GlEmoji,
      },
    });
  });

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

  it('renders information about merge request being merged', () => {
    expect(
      wrapper
        .find('.media-body')
        .text()
        .trim()
        .replace(/\s\s+/g, ' ')
        .replace(/[\r\n]+/g, ' '),
    ).toContain('Merging!');
  });

  it('renders branch information', () => {
    expect(
      wrapper
        .find('.mr-info-list')
        .text()
        .trim()
        .replace(/\s\s+/g, ' ')
        .replace(/[\r\n]+/g, ' '),
    ).toEqual('Merges changes into branch');

    expect(wrapper.find('a').attributes('href')).toBe('/branch-path');
  });
});