summaryrefslogtreecommitdiff
path: root/spec/frontend/pipelines/pipelines_artifacts_spec.js
blob: 83f6cb68ebae0297a01805af00d0a345d3da0004 (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
import { shallowMount } from '@vue/test-utils';
import { GlLink } from '@gitlab/ui';
import PipelineArtifacts from '~/pipelines/components/pipelines_list/pipelines_artifacts.vue';

describe('Pipelines Artifacts dropdown', () => {
  let wrapper;

  const createComponent = () => {
    wrapper = shallowMount(PipelineArtifacts, {
      propsData: {
        artifacts: [
          {
            name: 'artifact',
            path: '/download/path',
          },
          {
            name: 'artifact two',
            path: '/download/path-two',
          },
        ],
      },
    });
  };

  const findGlLink = () => wrapper.find(GlLink);
  const findAllGlLinks = () => wrapper.find('.dropdown-menu').findAll(GlLink);

  beforeEach(() => {
    createComponent();
  });

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

  it('should render a dropdown with all the provided artifacts', () => {
    expect(findAllGlLinks()).toHaveLength(2);
  });

  it('should render a link with the provided path', () => {
    expect(findGlLink().attributes('href')).toEqual('/download/path');

    expect(findGlLink().text()).toContain('artifact');
  });
});