summaryrefslogtreecommitdiff
path: root/spec/javascripts/vue_mr_widget/components/states/mr_widget_unresolved_discussions_spec.js
blob: 07da2d66744dd676356296ed53cedd6cf44a177b (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
import Vue from 'vue';
import unresolvedDiscussionsComponent from '~/vue_merge_request_widget/components/states/mr_widget_unresolved_discussions';

fdescribe('MRWidgetUnresolvedDiscussions', () => {
  describe('props', () => {
    it('should have props', () => {
      const { mr } = unresolvedDiscussionsComponent.props;

      expect(mr.type instanceof Object).toBeTruthy();
      expect(mr.required).toBeTruthy();
    });
  });

  describe('template', () => {
    let el;
    let vm;
    const path = 'foo/bar';

    beforeEach(() => {
      const Component = Vue.extend(unresolvedDiscussionsComponent);
      const mr = {
        createIssueToResolveDiscussionsPath: path,
      };
      vm = new Component({
        el: document.createElement('div'),
        propsData: { mr },
      });
      el = vm.$el;
    });

    it('should have correct elements', () => {
      expect(el.classList.contains('mr-widget-body')).toBeTruthy();
      expect(el.innerText).toContain('There are unresolved discussions. Please resolve these discussions or');
      expect(el.innerText).toContain('Create an issue to resolve them later');
      expect(el.querySelector('.js-create-issue').getAttribute('href')).toEqual(path);
    });

    it('should not show create issue button if user cannot create issue', (done) => {
      vm.mr.createIssueToResolveDiscussionsPath = '';

      Vue.nextTick(() => {
        expect(el.querySelector('.js-create-issue')).toEqual(null);
        expect(el.innerText).toContain('There are unresolved discussions. Please resolve these discussions.');
        done();
      });
    });
  });
});