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

locked_warning_spec.js « components « show « issues « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dd3c7c583806745b71238128bae294e20d3213ba (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
import { GlAlert, GlLink } from '@gitlab/ui';
import { mountExtended } from 'helpers/vue_test_utils_helper';
import { sprintf } from '~/locale';
import { TYPE_EPIC, TYPE_ISSUE } from '~/issues/constants';
import LockedWarning, { i18n } from '~/issues/show/components/locked_warning.vue';

describe('LockedWarning component', () => {
  let wrapper;

  const createComponent = (props = {}) => {
    wrapper = mountExtended(LockedWarning, {
      propsData: props,
    });
  };

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

  const findAlert = () => wrapper.findComponent(GlAlert);
  const findLink = () => wrapper.findComponent(GlLink);

  describe.each([TYPE_ISSUE, TYPE_EPIC])('with issuableType set to %s', (issuableType) => {
    let alert;
    let link;
    beforeEach(() => {
      createComponent({ issuableType });
      alert = findAlert();
      link = findLink();
    });

    afterEach(() => {
      alert = null;
      link = null;
    });

    it('displays a non-closable alert', () => {
      expect(alert.exists()).toBe(true);
      expect(alert.props('dismissible')).toBe(false);
    });

    it(`displays correct message`, async () => {
      expect(alert.text()).toMatchInterpolatedText(sprintf(i18n.alertMessage, { issuableType }));
    });

    it(`displays a link with correct text`, async () => {
      expect(link.exists()).toBe(true);
      expect(link.text()).toBe(`the ${issuableType}`);
    });
  });
});