summaryrefslogtreecommitdiff
path: root/spec/javascripts/vue_mr_widget/components/states/mr_widget_missing_branch_spec.js
blob: 3d7f4abd420d5aceaa532eb93e566330db8e0280 (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
import Vue from 'vue';
import missingBranchComponent from '~/vue_merge_request_widget/components/states/mr_widget_missing_branch.vue';
import mountComponent from '../../../helpers/vue_mount_component_helper';

describe('MRWidgetMissingBranch', () => {
  let vm;

  beforeEach(() => {
    const Component = Vue.extend(missingBranchComponent);
    vm = mountComponent(Component, { mr: { sourceBranchRemoved: true } });
  });

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

  describe('computed', () => {
    describe('missingBranchName', () => {
      it('should return proper branch name', () => {
        expect(vm.missingBranchName).toEqual('source');

        vm.mr.sourceBranchRemoved = false;
        expect(vm.missingBranchName).toEqual('target');
      });
    });
  });

  describe('template', () => {
    it('should have correct elements', () => {
      const el = vm.$el;
      const content = el.textContent.replace(/\n(\s)+/g, ' ').trim();

      expect(el.classList.contains('mr-widget-body')).toBeTruthy();
      expect(el.querySelector('button').getAttribute('disabled')).toBeTruthy();
      expect(content).toContain('source branch does not exist.');
      expect(content).toContain('Please restore it or use a different source branch');
    });
  });
});