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

edit_form_spec.js « lock « sidebar « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b1c3bfe3ef512ef9496cff06f6b3beaeafc19f6e (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
import { shallowMount } from '@vue/test-utils';
import EditForm from '~/sidebar/components/lock/edit_form.vue';
import { ISSUABLE_TYPE_ISSUE, ISSUABLE_TYPE_MR } from './constants';

describe('Edit Form Dropdown', () => {
  let wrapper;
  let issuableType; // Either ISSUABLE_TYPE_ISSUE or ISSUABLE_TYPE_MR
  let issuableDisplayName;

  const setIssuableType = pageType => {
    issuableType = pageType;
    issuableDisplayName = issuableType.replace(/_/g, ' ');
  };

  const findWarningText = () => wrapper.find('[data-testid="warning-text"]');

  const createComponent = ({ props }) => {
    wrapper = shallowMount(EditForm, {
      propsData: {
        isLocked: false,
        issuableDisplayName,
        ...props,
      },
    });
  };

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

  describe.each`
    pageType
    ${ISSUABLE_TYPE_ISSUE} | ${ISSUABLE_TYPE_MR}
  `('In $pageType page', ({ pageType }) => {
    beforeEach(() => {
      setIssuableType(pageType);
    });

    describe.each`
      isLocked | lockStatusText
      ${false} | ${'unlocked'}
      ${true}  | ${'locked'}
    `('when $lockStatusText', ({ isLocked }) => {
      beforeEach(() => {
        createComponent({ props: { isLocked } });
      });

      it(`the appropriate warning text is rendered`, () => {
        expect(findWarningText().element).toMatchSnapshot();
      });
    });
  });
});