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

47 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-03-08 18:12:59 +05:30
import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { mount } 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-03-08 18:12:59 +05:30
wrapper = mount(PipelineArtifacts, {
2020-05-24 23:13:21 +05:30
propsData: {
artifacts: [
{
name: 'artifact',
path: '/download/path',
},
{
name: 'artifact two',
path: '/download/path-two',
},
],
},
});
};
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-03-08 18:12:59 +05:30
expect(findFirstGlDropdownItem().find('a').attributes('href')).toEqual('/download/path');
2020-05-24 23:13:21 +05:30
2021-03-08 18:12:59 +05:30
expect(findFirstGlDropdownItem().text()).toContain('artifact');
2020-05-24 23:13:21 +05:30
});
});