Welcome to mirror list, hosted at ThFree Co, Russian Federation.

issuable_header_warnings_spec.js « components « issue_show « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5a166812d84218454c623e3f9533ead1d7045490 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex';
import IssuableHeaderWarnings from '~/issue_show/components/issuable_header_warnings.vue';
import createStore from '~/notes/stores';

const localVue = createLocalVue();
localVue.use(Vuex);

describe('IssuableHeaderWarnings', () => {
  let wrapper;
  let store;

  const findConfidential = () => wrapper.find('[data-testid="confidential"]');
  const findLocked = () => wrapper.find('[data-testid="locked"]');
  const confidentialIconName = () => findConfidential().attributes('name');
  const lockedIconName = () => findLocked().attributes('name');

  const createComponent = () => {
    wrapper = shallowMount(IssuableHeaderWarnings, { store, localVue });
  };

  beforeEach(() => {
    store = createStore();
  });

  afterEach(() => {
    wrapper.destroy();
    wrapper = null;
    store = null;
  });

  describe('when confidential is on', () => {
    beforeEach(() => {
      store.state.noteableData.confidential = true;

      createComponent();
    });

    it('renders the confidential icon', () => {
      expect(confidentialIconName()).toBe('eye-slash');
    });
  });

  describe('when confidential is off', () => {
    beforeEach(() => {
      store.state.noteableData.confidential = false;

      createComponent();
    });

    it('does not find the component', () => {
      expect(findConfidential().exists()).toBe(false);
    });
  });

  describe('when discussion locked is on', () => {
    beforeEach(() => {
      store.state.noteableData.discussion_locked = true;

      createComponent();
    });

    it('renders the locked icon', () => {
      expect(lockedIconName()).toBe('lock');
    });
  });

  describe('when discussion locked is off', () => {
    beforeEach(() => {
      store.state.noteableData.discussion_locked = false;

      createComponent();
    });

    it('does not find the component', () => {
      expect(findLocked().exists()).toBe(false);
    });
  });
});