2020-05-06 05:10:02 -04:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import { GlLink } from '@gitlab/ui';
|
2020-08-17 17:09:56 -04:00
|
|
|
import PipelineArtifacts from '~/pipelines/components/pipelines_list/pipelines_artifacts.vue';
|
2020-05-06 05:10:02 -04:00
|
|
|
|
|
|
|
describe('Pipelines Artifacts dropdown', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const createComponent = () => {
|
|
|
|
wrapper = shallowMount(PipelineArtifacts, {
|
|
|
|
propsData: {
|
|
|
|
artifacts: [
|
|
|
|
{
|
|
|
|
name: 'artifact',
|
|
|
|
path: '/download/path',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'artifact two',
|
|
|
|
path: '/download/path-two',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const findGlLink = () => wrapper.find(GlLink);
|
|
|
|
const findAllGlLinks = () => wrapper.find('.dropdown-menu').findAll(GlLink);
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render a dropdown with all the provided artifacts', () => {
|
|
|
|
expect(findAllGlLinks()).toHaveLength(2);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render a link with the provided path', () => {
|
|
|
|
expect(findGlLink().attributes('href')).toEqual('/download/path');
|
|
|
|
|
|
|
|
expect(findGlLink().text()).toContain('artifact');
|
|
|
|
});
|
|
|
|
});
|