debian-mirror-gitlab/spec/frontend/pipelines/pipelines_artifacts_spec.js
2021-03-11 19:13:27 +05:30

47 lines
1.2 KiB
JavaScript

import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
import PipelineArtifacts from '~/pipelines/components/pipelines_list/pipelines_artifacts.vue';
describe('Pipelines Artifacts dropdown', () => {
let wrapper;
const createComponent = () => {
wrapper = mount(PipelineArtifacts, {
propsData: {
artifacts: [
{
name: 'artifact',
path: '/download/path',
},
{
name: 'artifact two',
path: '/download/path-two',
},
],
},
});
};
const findFirstGlDropdownItem = () => wrapper.find(GlDropdownItem);
const findAllGlDropdownItems = () => wrapper.find(GlDropdown).findAll(GlDropdownItem);
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it('should render a dropdown with all the provided artifacts', () => {
expect(findAllGlDropdownItems()).toHaveLength(2);
});
it('should render a link with the provided path', () => {
expect(findFirstGlDropdownItem().find('a').attributes('href')).toEqual('/download/path');
expect(findFirstGlDropdownItem().text()).toContain('artifact');
});
});