Commit 33906894 authored by Miguel Rincon's avatar Miguel Rincon

Remove computed props checks for MR widget specs

This change removes references to computed props on
mr_widget_pipeline_spec, in favor of checking for rendered
output.
parent 0a020f7a
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import mockData from 'ee_jest/vue_mr_widget/mock_data'; import mockData from 'ee_jest/vue_mr_widget/mock_data';
import { trimText } from 'jest/helpers/text_helper'; import { trimText } from 'jest/helpers/text_helper';
import LinkedPipelinesMiniList from 'ee/vue_shared/components/linked_pipelines_mini_list.vue';
import pipelineComponent from '~/vue_merge_request_widget/components/mr_widget_pipeline.vue'; import pipelineComponent from '~/vue_merge_request_widget/components/mr_widget_pipeline.vue';
import mockLinkedPipelines from '../vue_shared/components/linked_pipelines_mock_data'; import mockLinkedPipelines from '../vue_shared/components/linked_pipelines_mock_data';
...@@ -8,6 +9,7 @@ describe('MRWidgetPipeline', () => { ...@@ -8,6 +9,7 @@ describe('MRWidgetPipeline', () => {
let wrapper; let wrapper;
const findPipelineInfoContainer = () => wrapper.find('[data-testid="pipeline-info-container"'); const findPipelineInfoContainer = () => wrapper.find('[data-testid="pipeline-info-container"');
const findPipelinesMiniList = () => wrapper.find(LinkedPipelinesMiniList);
function createComponent(pipeline) { function createComponent(pipeline) {
wrapper = mount(pipelineComponent, { wrapper = mount(pipelineComponent, {
...@@ -28,36 +30,6 @@ describe('MRWidgetPipeline', () => { ...@@ -28,36 +30,6 @@ describe('MRWidgetPipeline', () => {
wrapper.destroy(); wrapper.destroy();
}); });
describe('computed', () => {
describe('when upstream pipelines are passed', () => {
beforeEach(() => {
const pipeline = { ...mockData.pipeline, triggered_by: mockLinkedPipelines.triggered_by };
createComponent(pipeline);
});
it('should coerce triggeredBy into a collection', () => {
expect(wrapper.vm.triggeredBy).toHaveLength(1);
});
it('should render the linked pipelines mini list', () => {
expect(wrapper.find('.linked-pipeline-mini-list.is-upstream').exists()).toBe(true);
});
});
describe('when downstream pipelines are passed', () => {
beforeEach(() => {
const pipeline = { ...mockData.pipeline, triggered: mockLinkedPipelines.triggered };
createComponent(pipeline);
});
it('should render the linked pipelines mini list', () => {
expect(wrapper.find('.linked-pipeline-mini-list.is-downstream').exists()).toBe(true);
});
});
});
describe('for each type of pipeline', () => { describe('for each type of pipeline', () => {
let pipeline; let pipeline;
...@@ -96,4 +68,52 @@ describe('MRWidgetPipeline', () => { ...@@ -96,4 +68,52 @@ describe('MRWidgetPipeline', () => {
}); });
}); });
}); });
describe('pipeline graph', () => {
describe('when upstream pipelines are passed', () => {
beforeEach(() => {
const pipeline = { ...mockData.pipeline, triggered_by: mockLinkedPipelines.triggered_by };
createComponent(pipeline);
});
it('should render the linked pipelines mini list', () => {
expect(findPipelinesMiniList().exists()).toBe(true);
});
it('should render the linked pipelines mini list as an upstream list', () => {
expect(findPipelinesMiniList().classes('is-upstream')).toBe(true);
});
it('should add a single triggeredBy into an array', () => {
const triggeredBy = findPipelinesMiniList().props('triggeredBy');
expect(triggeredBy).toEqual(expect.any(Array));
expect(triggeredBy).toHaveLength(1);
expect(triggeredBy[0]).toBe(mockLinkedPipelines.triggered_by);
});
});
describe('when downstream pipelines are passed', () => {
beforeEach(() => {
const pipeline = { ...mockData.pipeline, triggered: mockLinkedPipelines.triggered };
createComponent(pipeline);
});
it('should render the linked pipelines mini list', () => {
expect(findPipelinesMiniList().exists()).toBe(true);
});
it('should render the linked pipelines mini list as a downstream list', () => {
expect(findPipelinesMiniList().classes('is-downstream')).toBe(true);
});
it('should pass the triggered pipelines', () => {
const triggered = findPipelinesMiniList().props('triggered');
expect(triggered).toBe(mockLinkedPipelines.triggered);
});
});
});
}); });
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