2019-10-14 09:07:54 +00:00
|
|
|
import { GlLink } from '@gitlab/ui';
|
2021-02-14 18:09:20 +00:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2019-10-14 09:07:54 +00:00
|
|
|
import ArtifactsList from '~/vue_merge_request_widget/components/artifacts_list.vue';
|
2021-01-08 18:10:43 +00:00
|
|
|
import { artifacts } from '../mock_data';
|
2019-10-14 09:07:54 +00:00
|
|
|
|
|
|
|
describe('Artifacts List', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const data = {
|
2021-01-08 18:10:43 +00:00
|
|
|
artifacts,
|
2019-10-14 09:07:54 +00:00
|
|
|
};
|
|
|
|
|
2020-12-23 21:10:24 +00:00
|
|
|
const mountComponent = (props) => {
|
2020-01-08 15:08:01 +00:00
|
|
|
wrapper = shallowMount(ArtifactsList, {
|
2019-10-14 09:07:54 +00:00
|
|
|
propsData: {
|
|
|
|
...props,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
mountComponent(data);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders list of artifacts', () => {
|
|
|
|
expect(wrapper.findAll('tbody tr').length).toEqual(data.artifacts.length);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders link for the artifact', () => {
|
|
|
|
expect(wrapper.find(GlLink).attributes('href')).toEqual(data.artifacts[0].url);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders artifact name', () => {
|
|
|
|
expect(wrapper.find(GlLink).text()).toEqual(data.artifacts[0].text);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders job url', () => {
|
2020-12-23 12:10:26 +00:00
|
|
|
expect(wrapper.findAll(GlLink).at(1).attributes('href')).toEqual(data.artifacts[0].job_path);
|
2019-10-14 09:07:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders job name', () => {
|
2020-12-23 12:10:26 +00:00
|
|
|
expect(wrapper.findAll(GlLink).at(1).text()).toEqual(data.artifacts[0].job_name);
|
2019-10-14 09:07:54 +00:00
|
|
|
});
|
|
|
|
});
|