debian-mirror-gitlab/spec/frontend/pipelines/pipelines_artifacts_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-12-11 22:18:48 +05:30
import { GlDropdown, GlDropdownItem, GlSprintf } from '@gitlab/ui';
2021-04-17 20:07:23 +05:30
import { shallowMount } from '@vue/test-utils';
2021-12-11 22:18:48 +05:30
import PipelineArtifacts from '~/pipelines/components/pipelines_list/pipelines_artifacts.vue';
2020-05-24 23:13:21 +05:30
describe('Pipelines Artifacts dropdown', () => {
let wrapper;
2021-06-08 01:23:25 +05:30
const artifacts = [
{
name: 'job my-artifact',
path: '/download/path',
},
{
name: 'job-2 my-artifact-2',
path: '/download/path-two',
},
];
const pipelineId = 108;
2021-12-11 22:18:48 +05:30
const createComponent = ({ mockArtifacts = artifacts } = {}) => {
2021-04-17 20:07:23 +05:30
wrapper = shallowMount(PipelineArtifacts, {
2020-05-24 23:13:21 +05:30
propsData: {
2021-06-08 01:23:25 +05:30
pipelineId,
2021-12-11 22:18:48 +05:30
artifacts: mockArtifacts,
2020-05-24 23:13:21 +05:30
},
2021-04-17 20:07:23 +05:30
stubs: {
GlSprintf,
},
2020-05-24 23:13:21 +05:30
});
};
2021-06-08 01:23:25 +05:30
const findDropdown = () => wrapper.findComponent(GlDropdown);
2022-10-11 01:57:18 +05:30
const findFirstGlDropdownItem = () => wrapper.findComponent(GlDropdownItem);
const findAllGlDropdownItems = () =>
wrapper.findComponent(GlDropdown).findAllComponents(GlDropdownItem);
2020-05-24 23:13:21 +05:30
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it('should render a dropdown with all the provided artifacts', () => {
2021-12-11 22:18:48 +05:30
createComponent();
2021-06-08 01:23:25 +05:30
expect(findAllGlDropdownItems()).toHaveLength(artifacts.length);
2020-05-24 23:13:21 +05:30
});
it('should render a link with the provided path', () => {
2021-12-11 22:18:48 +05:30
createComponent();
2020-05-24 23:13:21 +05:30
2021-06-08 01:23:25 +05:30
expect(findFirstGlDropdownItem().attributes('href')).toBe(artifacts[0].path);
2021-11-18 22:05:49 +05:30
expect(findFirstGlDropdownItem().text()).toBe(artifacts[0].name);
2021-06-08 01:23:25 +05:30
});
2021-12-11 22:18:48 +05:30
describe('with no artifacts', () => {
it('should not render the dropdown', () => {
createComponent({ mockArtifacts: [] });
2021-06-08 01:23:25 +05:30
2021-12-11 22:18:48 +05:30
expect(findDropdown().exists()).toBe(false);
2021-06-08 01:23:25 +05:30
});
2020-05-24 23:13:21 +05:30
});
});