summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_mr_widget/components/states/mr_widget_unresolved_discussions_spec.js
blob: 33e52f4fd36193aa5bc4ba46843f7b2e4c53f9e1 (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 Vue from 'vue';
import mountComponent from 'helpers/vue_mount_component_helper';
import UnresolvedDiscussions from '~/vue_merge_request_widget/components/states/unresolved_discussions.vue';
import { TEST_HOST } from 'helpers/test_constants';

describe('UnresolvedDiscussions', () => {
  const Component = Vue.extend(UnresolvedDiscussions);
  let vm;

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

  describe('with threads path', () => {
    beforeEach(() => {
      vm = mountComponent(Component, {
        mr: {
          createIssueToResolveDiscussionsPath: TEST_HOST,
        },
      });
    });

    it('should have correct elements', () => {
      expect(vm.$el.innerText).toContain(
        'There are unresolved threads. Please resolve these threads',
      );

      expect(vm.$el.innerText).toContain('Create an issue to resolve them later');
      expect(vm.$el.querySelector('.js-create-issue').getAttribute('href')).toEqual(TEST_HOST);
    });
  });

  describe('without threads path', () => {
    beforeEach(() => {
      vm = mountComponent(Component, { mr: {} });
    });

    it('should not show create issue link if user cannot create issue', () => {
      expect(vm.$el.innerText).toContain(
        'There are unresolved threads. Please resolve these threads',
      );

      expect(vm.$el.querySelector('.js-create-issue')).toEqual(null);
    });
  });
});