summaryrefslogtreecommitdiff
path: root/spec/frontend/work_items/components/work_item_comment_locked_spec.js
blob: 58491c4b09c088eb00ca3c775b12a920a8be5f4a (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
import { GlLink, GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import WorkItemCommentLocked from '~/work_items/components/work_item_comment_locked.vue';

const createComponent = ({ workItemType = 'Task', isProjectArchived = false } = {}) =>
  shallowMount(WorkItemCommentLocked, {
    propsData: {
      workItemType,
      isProjectArchived,
    },
  });

describe('WorkItemCommentLocked', () => {
  let wrapper;
  const findLockedIcon = () => wrapper.findComponent(GlIcon);
  const findLearnMoreLink = () => wrapper.findComponent(GlLink);

  it('renders the locked icon', () => {
    wrapper = createComponent();
    expect(findLockedIcon().props('name')).toBe('lock');
  });

  it('has the learn more link', () => {
    wrapper = createComponent();
    expect(findLearnMoreLink().attributes('href')).toBe(
      WorkItemCommentLocked.constantOptions.lockedIssueDocsPath,
    );
  });

  describe('when the project is archived', () => {
    beforeEach(() => {
      wrapper = createComponent({ isProjectArchived: true });
    });

    it('learn more link is directed to archived project docs path', () => {
      expect(findLearnMoreLink().attributes('href')).toBe(
        WorkItemCommentLocked.constantOptions.archivedProjectDocsPath,
      );
    });
  });
});