summaryrefslogtreecommitdiff
path: root/spec/javascripts/vue_mr_widget/components/states/mr_widget_nothing_to_merge_spec.js
blob: a8a02fa6b66a061c32bf8ffd1acad44e65921bd6 (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
import Vue from 'vue';
import nothingToMergeComponent from '~/vue_merge_request_widget/components/states/mr_widget_nothing_to_merge';

describe('MRWidgetNothingToMerge', () => {
  describe('template', () => {
    const Component = Vue.extend(nothingToMergeComponent);
    const newBlobPath = '/foo';
    const vm = new Component({
      el: document.createElement('div'),
      propsData: {
        mr: { newBlobPath },
      },
    });

    it('should have correct elements', () => {
      expect(vm.$el.classList.contains('mr-widget-body')).toBeTruthy();
      expect(vm.$el.querySelector('a').href).toContain(newBlobPath);
      expect(vm.$el.innerText).toContain('Currently there are no changes in this merge request\'s source branch');
      expect(vm.$el.innerText).toContain('Please push new commits or use a different branch.');
    });

    it('should not show new blob link if there is no link available', () => {
      vm.mr.newBlobPath = null;
      Vue.nextTick(() => {
        expect(vm.$el.querySelector('a')).toEqual(null);
      });
    });
  });
});