Commit 82ee4b7f authored by Illya Klymov's avatar Illya Klymov

Merge branch 'migrate-artifacts-karma-spec' into 'master'

Migrate pipelines artifacts spec to jest

See merge request gitlab-org/gitlab!30996
parents 52952037 3b50eec9
import { shallowMount } from '@vue/test-utils';
import PipelineArtifacts from '~/pipelines/components/pipelines_artifacts.vue';
import { GlLink } from '@gitlab/ui';
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');
});
});
import Vue from 'vue';
import artifactsComp from '~/pipelines/components/pipelines_artifacts.vue';
describe('Pipelines Artifacts dropdown', () => {
let component;
let artifacts;
beforeEach(() => {
const ArtifactsComponent = Vue.extend(artifactsComp);
artifacts = [
{
name: 'artifact',
path: '/download/path',
},
];
component = new ArtifactsComponent({
propsData: {
artifacts,
},
}).$mount();
});
it('should render a dropdown with the provided artifacts', () => {
expect(component.$el.querySelectorAll('.dropdown-menu li').length).toEqual(artifacts.length);
});
it('should render a link with the provided path', () => {
expect(component.$el.querySelector('.dropdown-menu li a').getAttribute('href')).toEqual(
artifacts[0].path,
);
expect(component.$el.querySelector('.dropdown-menu li a').textContent).toContain(
artifacts[0].name,
);
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment