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

mr_widget_merge_help_spec.js « components « vue_mr_widget « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 00e79a224854e9ee85adf033bf70b97eeba6e214 (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
65
66
67
68
69
70
import Vue from 'vue';
import mountComponent from 'helpers/vue_mount_component_helper';
import mergeHelpComponent from '~/vue_merge_request_widget/components/mr_widget_merge_help.vue';

describe('MRWidgetMergeHelp', () => {
  let vm;
  let Component;

  beforeEach(() => {
    Component = Vue.extend(mergeHelpComponent);
  });

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

  describe('with missing branch', () => {
    beforeEach(() => {
      vm = mountComponent(Component, {
        missingBranch: 'this-is-not-the-branch-you-are-looking-for',
      });
    });

    it('renders missing branch information', () => {
      expect(
        vm.$el.textContent
          .trim()
          .replace(/[\r\n]+/g, ' ')
          .replace(/\s\s+/g, ' '),
      ).toEqual(
        'If the this-is-not-the-branch-you-are-looking-for branch exists in your local repository, you can merge this merge request manually using the command line',
      );
    });

    it('renders button to open help modal', () => {
      expect(vm.$el.querySelector('.js-open-modal-help').getAttribute('data-target')).toEqual(
        '#modal_merge_info',
      );

      expect(vm.$el.querySelector('.js-open-modal-help').getAttribute('data-toggle')).toEqual(
        'modal',
      );
    });
  });

  describe('without missing branch', () => {
    beforeEach(() => {
      vm = mountComponent(Component);
    });

    it('renders information about how to merge manually', () => {
      expect(
        vm.$el.textContent
          .trim()
          .replace(/[\r\n]+/g, ' ')
          .replace(/\s\s+/g, ' '),
      ).toEqual('You can merge this merge request manually using the command line');
    });

    it('renders element to open a modal', () => {
      expect(vm.$el.querySelector('.js-open-modal-help').getAttribute('data-target')).toEqual(
        '#modal_merge_info',
      );

      expect(vm.$el.querySelector('.js-open-modal-help').getAttribute('data-toggle')).toEqual(
        'modal',
      );
    });
  });
});