summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_mr_widget/components/mr_widget_merge_help_spec.js
blob: 53a74bf7456819b838eff9b2ea093edd7934d0d9 (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
import { shallowMount } from '@vue/test-utils';
import MergeHelpComponent from '~/vue_merge_request_widget/components/mr_widget_merge_help.vue';

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

  const createComponent = ({ props = {} } = {}) => {
    wrapper = shallowMount(MergeHelpComponent, {
      propsData: {
        missingBranch: 'this-is-not-the-branch-you-are-looking-for',
        ...props,
      },
    });
  };

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

  describe('with missing branch', () => {
    beforeEach(() => {
      createComponent();
    });

    it('renders missing branch information', () => {
      expect(wrapper.find('.mr-widget-help').text()).toContain(
        'If the this-is-not-the-branch-you-are-looking-for branch exists in your local repository',
      );
    });
  });

  describe('without missing branch', () => {
    beforeEach(() => {
      createComponent({
        props: { missingBranch: '' },
      });
    });

    it('renders information about how to merge manually', () => {
      expect(wrapper.find('.mr-widget-help').text()).toContain(
        'You can merge this merge request manually',
      );
    });
  });
});