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

50 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-04-17 20:07:23 +05:30
import { GlDropdown, GlDropdownItem, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
2020-10-24 23:57:45 +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;
const createComponent = () => {
2021-04-17 20:07:23 +05:30
wrapper = shallowMount(PipelineArtifacts, {
2020-05-24 23:13:21 +05:30
propsData: {
artifacts: [
{
2021-04-17 20:07:23 +05:30
name: 'job my-artifact',
2020-05-24 23:13:21 +05:30
path: '/download/path',
},
{
2021-04-17 20:07:23 +05:30
name: 'job-2 my-artifact-2',
2020-05-24 23:13:21 +05:30
path: '/download/path-two',
},
],
},
2021-04-17 20:07:23 +05:30
stubs: {
GlSprintf,
},
2020-05-24 23:13:21 +05:30
});
};
2021-03-08 18:12:59 +05:30
const findFirstGlDropdownItem = () => wrapper.find(GlDropdownItem);
const findAllGlDropdownItems = () => wrapper.find(GlDropdown).findAll(GlDropdownItem);
2020-05-24 23:13:21 +05:30
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it('should render a dropdown with all the provided artifacts', () => {
2021-03-08 18:12:59 +05:30
expect(findAllGlDropdownItems()).toHaveLength(2);
2020-05-24 23:13:21 +05:30
});
it('should render a link with the provided path', () => {
2021-04-17 20:07:23 +05:30
expect(findFirstGlDropdownItem().attributes('href')).toBe('/download/path');
2020-05-24 23:13:21 +05:30
2021-04-17 20:07:23 +05:30
expect(findFirstGlDropdownItem().text()).toBe('Download job my-artifact artifact');
2020-05-24 23:13:21 +05:30
});
});