Commit 9f953fea authored by Denys Mishunov's avatar Denys Mishunov

Merge branch 'migrate_mr_widget_pipeline_container_spec_to_jest' into 'master'

Migrate mr_widget_pipeline_container_spec to jest

See merge request gitlab-org/gitlab!30585
parents 19075c3d d2963b8f
import { mount, createLocalVue } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import MrWidgetPipelineContainer from '~/vue_merge_request_widget/components/mr_widget_pipeline_container.vue'; import MrWidgetPipelineContainer from '~/vue_merge_request_widget/components/mr_widget_pipeline_container.vue';
import MrWidgetPipeline from '~/vue_merge_request_widget/components/mr_widget_pipeline.vue'; import MrWidgetPipeline from '~/vue_merge_request_widget/components/mr_widget_pipeline.vue';
import ArtifactsApp from '~/vue_merge_request_widget/components/artifacts_list_app.vue'; import ArtifactsApp from '~/vue_merge_request_widget/components/artifacts_list_app.vue';
import { mockStore } from '../mock_data'; import { mockStore } from '../mock_data';
import MockAdapter from 'axios-mock-adapter';
const localVue = createLocalVue(); import axios from '~/lib/utils/axios_utils';
describe('MrWidgetPipelineContainer', () => { describe('MrWidgetPipelineContainer', () => {
let wrapper; let wrapper;
let mock;
const factory = (props = {}) => { const factory = (props = {}) => {
wrapper = mount(localVue.extend(MrWidgetPipelineContainer), { wrapper = mount(MrWidgetPipelineContainer, {
propsData: { propsData: {
mr: Object.assign({}, mockStore), mr: Object.assign({}, mockStore),
...props, ...props,
}, },
localVue,
}); });
}; };
beforeEach(() => {
mock = new MockAdapter(axios);
mock.onGet().reply(200, {});
});
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
}); });
...@@ -30,21 +35,19 @@ describe('MrWidgetPipelineContainer', () => { ...@@ -30,21 +35,19 @@ describe('MrWidgetPipelineContainer', () => {
it('renders pipeline', () => { it('renders pipeline', () => {
expect(wrapper.find(MrWidgetPipeline).exists()).toBe(true); expect(wrapper.find(MrWidgetPipeline).exists()).toBe(true);
expect(wrapper.find(MrWidgetPipeline).props()).toEqual( expect(wrapper.find(MrWidgetPipeline).props()).toMatchObject({
jasmine.objectContaining({ pipeline: mockStore.pipeline,
pipeline: mockStore.pipeline, pipelineCoverageDelta: mockStore.pipelineCoverageDelta,
pipelineCoverageDelta: mockStore.pipelineCoverageDelta, ciStatus: mockStore.ciStatus,
ciStatus: mockStore.ciStatus, hasCi: mockStore.hasCI,
hasCi: mockStore.hasCI, sourceBranch: mockStore.sourceBranch,
sourceBranch: mockStore.sourceBranch, sourceBranchLink: mockStore.sourceBranchLink,
sourceBranchLink: mockStore.sourceBranchLink, });
}),
);
}); });
it('renders deployments', () => { it('renders deployments', () => {
const expectedProps = mockStore.deployments.map(dep => const expectedProps = mockStore.deployments.map(dep =>
jasmine.objectContaining({ expect.objectContaining({
deployment: dep, deployment: dep,
showMetrics: false, showMetrics: false,
}), }),
...@@ -65,21 +68,19 @@ describe('MrWidgetPipelineContainer', () => { ...@@ -65,21 +68,19 @@ describe('MrWidgetPipelineContainer', () => {
it('renders pipeline', () => { it('renders pipeline', () => {
expect(wrapper.find(MrWidgetPipeline).exists()).toBe(true); expect(wrapper.find(MrWidgetPipeline).exists()).toBe(true);
expect(wrapper.find(MrWidgetPipeline).props()).toEqual( expect(wrapper.find(MrWidgetPipeline).props()).toMatchObject({
jasmine.objectContaining({ pipeline: mockStore.mergePipeline,
pipeline: mockStore.mergePipeline, pipelineCoverageDelta: mockStore.pipelineCoverageDelta,
pipelineCoverageDelta: mockStore.pipelineCoverageDelta, ciStatus: mockStore.ciStatus,
ciStatus: mockStore.ciStatus, hasCi: mockStore.hasCI,
hasCi: mockStore.hasCI, sourceBranch: mockStore.targetBranch,
sourceBranch: mockStore.targetBranch, sourceBranchLink: mockStore.targetBranch,
sourceBranchLink: mockStore.targetBranch, });
}),
);
}); });
it('renders deployments', () => { it('renders deployments', () => {
const expectedProps = mockStore.postMergeDeployments.map(dep => const expectedProps = mockStore.postMergeDeployments.map(dep =>
jasmine.objectContaining({ expect.objectContaining({
deployment: dep, deployment: dep,
showMetrics: true, showMetrics: true,
}), }),
......
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