summaryrefslogtreecommitdiff
path: root/spec/javascripts/vue_mr_widget/components/mr_widget_maintainer_edit_spec.js
blob: cee22d5342a2f422f07078c11d1ad172cc87b052 (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
import Vue from 'vue';
import maintainerEditComponent from '~/vue_merge_request_widget/components/mr_widget_maintainer_edit.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';

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

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

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

  describe('when a maintainer is allowed to edit', () => {
    beforeEach(() => {
      vm = mountComponent(Component, {
        maintainerEditAllowed: true,
      });
    });

    it('it renders the message', () => {
      expect(vm.$el.textContent.trim()).toEqual('Allows edits from maintainers');
    });
  });

  describe('when a maintainer is not allowed to edit', () => {
    beforeEach(() => {
      vm = mountComponent(Component, {
        maintainerEditAllowed: false,
      });
    });

    it('hides the message', () => {
      expect(vm.$el.textContent.trim()).toEqual('');
    });
  });
});