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