summaryrefslogtreecommitdiff
path: root/spec/javascripts/vue_pipelines_index/pipelines_artifacts_spec.js
blob: f7f49649c1c6b52525093416f6c94a713e50a687 (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
import Vue from 'vue';
import artifactsComp from '~/vue_pipelines_index/components/pipelines_artifacts';

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

  beforeEach(() => {
    const ArtifactsComponent = Vue.extend(artifactsComp);

    artifacts = [
      {
        name: 'artifact',
        path: '/download/path',
      },
    ];

    component = new ArtifactsComponent({
      propsData: {
        artifacts,
      },
    }).$mount();
  });

  it('should render a dropdown with the provided artifacts', () => {
    expect(
      component.$el.querySelectorAll('.dropdown-menu li').length,
    ).toEqual(artifacts.length);
  });

  it('should render a link with the provided path', () => {
    expect(
      component.$el.querySelector('.dropdown-menu li a').getAttribute('href'),
    ).toEqual(artifacts[0].path);

    expect(
      component.$el.querySelector('.dropdown-menu li a span').textContent,
    ).toContain(artifacts[0].name);
  });
});