summaryrefslogtreecommitdiff
path: root/spec/javascripts/vue_mr_widget/components/states/mr_widget_merging_spec.js
blob: 57773d1648a344ae847541b49ba311e2aa6eb989 (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
import Vue from 'vue';
import mergingComponent from '~/vue_merge_request_widget/components/states/mr_widget_merging.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';

describe('MRWidgetMerging', () => {
  let vm;
  beforeEach(() => {
    const Component = Vue.extend(mergingComponent);

    vm = mountComponent(Component, {
      mr: {
        targetBranchPath: '/branch-path',
        targetBranch: 'branch',
      },
    });
  });

  afterEach(() => {
    vm.$destroy();
  });

  it('renders information about merge request being merged', () => {
    expect(
      vm.$el
        .querySelector('.media-body')
        .textContent.trim()
        .replace(/\s\s+/g, ' ')
        .replace(/[\r\n]+/g, ' '),
    ).toContain('This merge request is in the process of being merged');
  });

  it('renders branch information', () => {
    expect(
      vm.$el
        .querySelector('.mr-info-list')
        .textContent.trim()
        .replace(/\s\s+/g, ' ')
        .replace(/[\r\n]+/g, ' '),
    ).toEqual('The changes will be merged into branch');

    expect(vm.$el.querySelector('a').getAttribute('href')).toEqual('/branch-path');
  });
});