2021-06-08 01:23:25 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2021-03-08 18:12:59 +05:30
|
|
|
import LinksInner from '~/pipelines/components/graph_shared/links_inner.vue';
|
2021-03-11 19:13:27 +05:30
|
|
|
import LinksLayer from '~/pipelines/components/graph_shared/links_layer.vue';
|
2021-03-08 18:12:59 +05:30
|
|
|
import { generateResponse, mockPipelineResponse } from '../graph/mock_data';
|
|
|
|
|
|
|
|
describe('links layer component', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
const findLinksInner = () => wrapper.findComponent(LinksInner);
|
2021-03-08 18:12:59 +05:30
|
|
|
|
|
|
|
const pipeline = generateResponse(mockPipelineResponse, 'root/fungi-xoxo');
|
|
|
|
const containerId = `pipeline-links-container-${pipeline.id}`;
|
|
|
|
const slotContent = "<div>Ceci n'est pas un graphique</div>";
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
containerId,
|
|
|
|
containerMeasurements: { width: 400, height: 400 },
|
|
|
|
pipelineId: pipeline.id,
|
|
|
|
pipelineData: pipeline.stages,
|
2021-06-08 01:23:25 +05:30
|
|
|
showLinks: false,
|
2021-03-08 18:12:59 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
const createComponent = ({ mountFn = shallowMount, props = {} } = {}) => {
|
|
|
|
wrapper = mountFn(LinksLayer, {
|
|
|
|
propsData: {
|
|
|
|
...defaultProps,
|
|
|
|
...props,
|
|
|
|
},
|
|
|
|
slots: {
|
|
|
|
default: slotContent,
|
|
|
|
},
|
|
|
|
stubs: {
|
|
|
|
'links-inner': true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
describe('with show links off', () => {
|
2021-03-08 18:12:59 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the default slot', () => {
|
|
|
|
expect(wrapper.html()).toContain(slotContent);
|
|
|
|
});
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
it('does not render inner links component', () => {
|
|
|
|
expect(findLinksInner().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with show links on', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({
|
|
|
|
props: {
|
|
|
|
showLinks: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the default slot', () => {
|
|
|
|
expect(wrapper.html()).toContain(slotContent);
|
|
|
|
});
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
it('renders the inner links component', () => {
|
|
|
|
expect(findLinksInner().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
describe('with width or height measurement at 0', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({ props: { containerMeasurements: { width: 0, height: 100 } } });
|
|
|
|
});
|
2021-03-08 18:12:59 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
it('renders the default slot', () => {
|
|
|
|
expect(wrapper.html()).toContain(slotContent);
|
|
|
|
});
|
2021-03-08 18:12:59 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
it('does not render the inner links component', () => {
|
|
|
|
expect(findLinksInner().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
2021-03-08 18:12:59 +05:30
|
|
|
});
|