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

file_item_spec.js « file-tree « components « pipeline_editor « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f12ac14c6be5ae017723cc32a302ce2c716f858a (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 { GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import FileIcon from '~/vue_shared/components/file_icon.vue';
import PipelineEditorFileTreeItem from '~/pipeline_editor/components/file_tree/file_item.vue';
import { mockIncludesWithBlob, mockDefaultIncludes } from '../../mock_data';

describe('Pipeline editor file nav', () => {
  let wrapper;

  const createComponent = ({ file = mockDefaultIncludes } = {}) => {
    wrapper = shallowMount(PipelineEditorFileTreeItem, {
      propsData: {
        file,
      },
    });
  };

  const fileIcon = () => wrapper.findComponent(FileIcon);
  const link = () => wrapper.findComponent(GlLink);

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

  describe('template', () => {
    beforeEach(() => {
      createComponent();
    });

    it('renders file icon', () => {
      expect(fileIcon().exists()).toBe(true);
    });

    it('renders file name', () => {
      expect(wrapper.text()).toBe(mockDefaultIncludes.location);
    });

    it('links to raw path by default', () => {
      expect(link().attributes('href')).toBe(mockDefaultIncludes.raw);
    });
  });

  describe('when file has blob link', () => {
    beforeEach(() => {
      createComponent({ file: mockIncludesWithBlob });
    });

    it('links to blob path', () => {
      expect(link().attributes('href')).toBe(mockIncludesWithBlob.blob);
    });
  });
});